-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa.py
More file actions
35 lines (29 loc) · 929 Bytes
/
Copy pathqa.py
File metadata and controls
35 lines (29 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
answers = {
"what is your name": "My name is Copilot.",
"what is 2 + 2": "4",
"what color is the sky": "Blue",
"how are you": "I'm fine, thanks.",
}
keywords = {
"name": "It sounds like you're asking about a name.",
"color": "It looks like a question about color.",
"how": "You may be asking how something is."
}
def guess_answer(question: str) -> str:
q = question.strip().lower()
if q in answers:
return answers[q]
for word, guess in keywords.items():
if word in q:
return guess
return "I don't know, but I'm guessing the answer is something interesting."
def main():
print("Ask a question and I'll try to guess the answer.")
while True:
question = input("Question: ")
if not question:
print("Goodbye!")
break
print("Answer:", guess_answer(question))
if __name__ == "__main__":
main()