A chatbot is a computer program designed to emulate human conversation. For this program, you will use if statements, user input, and random numbers to create a basic chatbot.

The Scenario
You have decided to start a website and are creating a chatbot prototype to show investors so you can raise money and launch your website.

Your chatbot should ask the user the following (minimum requirements for the grader) and then give answers depending on the answers the user inputs:

at least 5 questions
at least 2 if-elif-else statements
the use of the random module and randomly generated numbers
Based on these criteria, some responses will be based on what the user types and some will be based on random numbers.

For example, if the chatbot asks how the user is doing, your chatbot might respond I’m sorry to hear that. in response to a user input of sad, or That's great! in response to a user input of happy.

Additionally, you could also have a random number generated between, say, 1 and 3 and have a corresponding response depending on the number to randomly answer with That is great to hear. or So interesting., and so on.

Sample Run
Please note that due to the infinite possibility of questions that can be asked, your program will be different—this is only one example.

What is your first name?

Pascal

What is your last name?

Smith

Hi there, Pascal Smith, nice to meet you!


How old are you?

17

17 is a good age.

You are old enough to drive.


So, Pascal, how are you today?

Happy

You are happy.

That is good to hear.

Tell me more.


I am just happy.

That's good to hear.


Well, Pascal, it has been nice chatting with you.

Respuesta :

In python:

import random

good_responses = (["That's cool!", "Wow!", "That's great to hear!", "Tell me more"])

bad_responses = (["I'm sorry", "That sucks!"])

first_name = input("What's your first name? ")

last_name = input("What's your last name? ")

print(f"Hello {first_name} {last_name}, nice to meet you!")

age = int(input(f"How old are you, {first_name}? "))

if age > 17:

   print("Wow, you're old enough to vote!")

else:

   print("Quite young, aren't you.")

color = input("What's your favorite color? ")

print(good_responses[random.randint(0,3)])

feeling = input("How are you feeling? (sad/happy) ")

if feeling == 'sad':

   print(bad_responses[random.randint(0,1)])

else:

   print(good_responses[random.randint(0,3)])

print(f"It's been nice chatting with you, {first_name}!")

I hope this helps!

In this exercise we have to use the knowledge of computational language in python to write the code.

This code can be found in the attached image.

To make it simpler the code is described as:

import random

good_responses = (["That's cool!", "Wow!", "That's great to hear!", "Tell me more"])

bad_responses = (["I'm sorry", "That sad"])

first_name = input("What's your first name? ")

last_name = input("What's your last name? ")

print("Hello {first_name} {last_name}, nice to meet you!")

age = int(input(f"How old are you, {first_name}? "))

if age > 17:

  print("Wow, you're old enough to vote!")

else:

  print("Quite young, aren't you.")

See more about python at brainly.com/question/22841107

Ver imagen lhmarianateixeira
ACCESS MORE
EDU ACCESS
Universidad de Mexico