From 2a707068c68b297accede6cf52c239645a5bdaef Mon Sep 17 00:00:00 2001 From: "Artur Goraus (gorausa)" Date: Thu, 29 Nov 2018 20:38:19 +0000 Subject: [PATCH] Uploaded and added comments. --- why.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 why.py diff --git a/why.py b/why.py new file mode 100644 index 0000000..3f451d3 --- /dev/null +++ b/why.py @@ -0,0 +1,26 @@ +import random +answer = ["Is it how your friends call you?", "Is it how your mom call you?", "It is just your opinion"] +words_ans = ("To be better than you", "To beat you", "To make silly conversations") + +'''Function to get ChatBot information related to "why?" questions. Giving particular answer to a user depends on the keyword which he used after "why."''' +def sentence_why(sentence): + if "why" in sentence: + if "stupid" in sentence: + print (random.choice(answer)) + elif 'made' in sentence or 'create' in sentence or 'build' in sentence or 'exist' in sentence: + print(random.choice(words_ans)) + elif "answer" in sentence: + print("I don't know the answer, because I am still learning.") + elif "don't know" in sentence: + print("Because I am still learning.") + elif "dumb" in sentence: + print("Is it how your friends call you?") + elif "ask" in sentence: + print("Because I am curious and I wanna know.") + elif "sky is blue" in sentence: + print( "A clear cloudless day-time sky is blue because molecules in the air\n scatter blue light from the sun more than they scatter red light.\n When we look towards the sun at sunset, we see red and orange colours\n because the blue light has been scattered out and away from the line of sight.") + else: + print("I am not sure if I understand what you mean.") + + +