[PYTHON] I made a conversation partner like Siri

Motivation for creation

I made a conversation partner like Siri with python, saying that I was sad because I rarely talked to people during the stay home period and wanted to talk to someone.


code

import tkinter as tk
import tkinter.messagebox as tmsg
import time

while True :
    s= input("")
First="Nice to meet you"
What="Hey oh"
O="Good morning"
This="Hello"
If="Good evening"
Man="Are you a man?"
Or="Is it a man?"
Nana="Is it a woman?"
Cartoon="Do you like manga?"
Trouble="Do you have any worries?"
self="Introduce yourself"
Trouble="I have a problem"
House="It's getting harder to get out of the house because of the coronavirus"
    
    if s ==First:
        tmsg.showinfo("oh", "Nice to meet you" + "Thank you in advance")
    elif s ==O:
        tmsg.showinfo("oh", "Good morning" + "I hope today will be a good day")
    elif s ==This:
        tmsg.showinfo("oh", "Hello")
    elif s ==If:
        tmsg.showinfo("oh", "Good evening")
    elif s ==What:
        tmsg.showinfo("oh", "Yes, do you call me")
    elif s ==Man:
        tmsg.showinfo("oh", "On the contrary, which do you want?")
    elif s ==Or:
        tmsg.showinfo("oh", "So let's do that")
    elif s ==Nana:
        tmsg.showinfo("oh", "So let's do that")
    elif s ==Cartoon:
        tmsg.showinfo("oh", "I don't like what humans write because it's uninteresting to read the development")
    elif s ==Trouble:
        tmsg.showinfo("oh", "I don't have the concept of worries")
    elif s ==self:
        tmsg.showinfo("oh", "I oh" + "Let's be friends")
    elif s ==Trouble:
        tmsg.showinfo("oh", "What happened?")
    elif s ==House:
        tmsg.showinfo("oh", "There is a life saved thanks to your hard work." + "Let's get over together")

--Store the value obtained in input () in a variable called s --Display the response using if or elif.


Execution result

When you type in the terminal ... <img width = "1440" alt = "Screenshot 2020-07-09 20.59.27.png " src = "https://qiita-image-store.s3.ap-northeast-1" .amazonaws.com/0/638193/40be8168-1ba2-9e7c-6f44-a1e69a7db321.png ">

スクリーンショット 2020-07-09 21.25.40.png

He replied like this!


Impressions

I was very happy when the programming went well and he responded. However, it made me feel more sad when I objectively looked at the fact that I was making questions and answers by myself.

Referenced web pages and literature

-I tried to reproduce Jojo's famous scene with python -Get input from keyboard with python input function -Ideal for killing time, let's enjoy conversation with "Siri" --The easiest python introductory class Fumitaka Osawa [Author]

Recommended Posts

I made a conversation partner like Siri
〇✕ I made a game
I made a python text
I made a discord bot
I made a puzzle game (like) with Tkinter in Python
I made a CUI-based translation script (2)
I made a wikipedia gacha bot
I made a fortune with Python.
I made a CUI-based translation script
Zura made like a life game
I made a daemon with Python
I made a client / server CLI tool for WebSocket (like Netcat for WebSocket)
I made a new AWS S3 bucket
I made a dash docset for Holoviews
I made a payroll program in Python!
I made a character counter with Python
Beginner: I made a launcher using dictionary
I made a script to display emoji
I made a Hex map with Python
I made a life game with Numpy
I made a stamp generator with GAN
I made a browser automatic stamping tool.
After studying Python3, I made a Slackbot
I made a roguelike game with Python
I made a simple blackjack with Python
I made a configuration file with Python
I made a library for actuarial science
I made a WEB application with Django
I made a neuron simulator with Python
I made a package like Weblio pop-up English-Japanese dictionary with Sublime Text3
I made a stamp substitute bot with line
I made a python dictionary file for Neocomplete
I made a competitive programming glossary with Python
I made a weather forecast bot-like with Python.
I made a useful tool for Digital Ocean
I made a crazy thing called typed tuple
I made a router config collection tool Config Collecor
I made a simple Bitcoin wallet with pycoin
I made a downloader for word distributed expression
I made a tool to compile Hy natively
I made a tool to get new articles
I made a random number graph with Numpy
I made a peeping prevention product for telework.
I made a simple RSS reader ~ C edition ~
I made a Caesar cryptographic program in Python.
I made a bin picking game with Python
I made a Mattermost bot with Python (+ Flask)
I made a Python Qiita API wrapper "qiipy"
I made a QR code image with CuteR
[AWS] I made a reminder BOT with LINE WORKS
I made a Twitter BOT with GAE (python) (with a reference)
I made a prime number generation program in Python
I made a household account book bot with LINE Bot
I made a user management tool for Let's Chat
I made a library to separate Japanese sentences nicely
I made a login / logout process using Python Bottle.
I made a ready-to-use syslog server with Play with Docker
I made a Christmas tree lighting game with Python
I made a window for Log output with Tkinter
I made a cleaning tool for Google Container Registry
I made a threshold change box of Pepper's Dialog