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.
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.
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 ">
He replied like this!
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.
-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