Need help to solve these tasks
here’s the output please help me:
here’s my code:
import re
import random
class AlienBot:
# potential negative responses
negative_responses = ("no", "nope", "nah", "naw", "not a chance", "sorry")
# keywords for exiting the conversation
exit_commands = ("quit", "pause", "exit", "goodbye", "bye", "later")
# random starter questions
random_questions = (
"Why are you here? ",
"Are there many humans like you? ",
"What do you consume for sustenance? ",
"Is there intelligent life on this planet? ",
"Does Earth have a leader? ",
"What planets have you visited? ",
"What technology do you have on this planet? "
)
def __init__(self):
self.alienbabble = {"describe_planet_intent": r".*\s*your planet.*",
'answer_why_intent': r'',
'cubed_intent': r'',
}
# Define .greet() below:
def greet(self):
name = input("What is your name? ")
will_help = input(
f"Hi {name}, I'm Etcetera. I'm not from this planet. Will you help me learn about your planet? ")
if will_help in self.negative_responses:
print("Your Choice")
return
self.chat()
# Define make_exit() here:
def make_exit(self, reply):
for exit_command in self.exit_commands:
if exit_command in reply:
print("Okay, then have a nice earth day!")
return True
# Define chat() next:
def chat(self):
reply = input(random.choice(self.random_questions)).lower()
while not self.make_exit(reply):
reply = input(self.match_reply(reply))
# Define match_reply() below:
def match_reply(self, reply):
for key, values in self.alienbabble.items():
for key, regex_pattern in self.alienbabble.items():
found_match = re.match(regex_pattern, reply)
if found_match and key == "describe_planet_intent":
self.describe_planet_intent()
elif found_match and key == "answer_why_intent":
self.answer_why_intent()
return
# Define describe_planet_intent()
def describe_planet_intent(self):
return input("Inside describe_planet_intent ")
# Define answer_why_intent()
def answer_why_intent(self):
return input("Inside answer_why_intent ")
# Define cubed_intent
def cubed_intent(self, number):
return input("Inside cubed_intent ")
def no_match_intent(self):
return input("I do not understand your question")
# Create chat bot instance and other stuff
my_bot = AlienBot()
my_bot.greet()