Question

[PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a...

[PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a human using text. Your program should involve asking the user questions and having the computer respond in a reasonably intelligent fashion based on those answers. For example, here is a sample chat:

ChatBot: Welcome, I am Chatbot . What is your name?

User: My name is Abby .

ChatBot: Hello Abby. How old are you?

User: 22. <---- Input

ChatBot: That is older than I am! Can you guess my age?

User: 11. <----- Input

Chatbot: That is incorrect. My age is between 5 and 10. Guess again.

User: 4. <----- Input

Chatbot: Correct! What is your favourite animal?

User: Cat. <------ Input

Chatbot: I do not like cats. I prefer dogs.

etc.

You may make your chatbot ask and answer any questions, so long as you include at least the following:

- One if/else statement.

- One if statement using OR.

- One if statement using AND.

- One if statement using both AND and OR.

- At least one loop.

- At least one calculation involving a numerical answer that the user inputted (for example, in the above chat, the chatbot might calculate the difference between its age and the user’s age and output this).

The input only has to be one word or numbers, doesn't have to be a phrase.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

print("\n\n")

print("Chatbot: Welcome, I am Chatbot. What is your name?")

name = input("")

print("\nChatbot: Hello "+name+". How old are you?")

age = int(input(""))

if age >= 5 and age <= 10:

               print("We are both of same age! What a coincidence!!")

              

else:

               if age < 5:

                              print("\nChatbot: You're younger than me! Can you guess my age?")

               else:

                              print("\nChatbot: That is older than I am! Can you guess my age?")

               myage = int(input(""))

               if myage > 5 or myage < 10:

                              print("\nChatbot: That is incorrect. My age is between 5 and 10. Guess again.")

               myage =int(input(""))

               while myage!= 7:

                              print("\nChatbot: That is incorrect. My age is between 5 and 10. Guess again.")

                              myage = int(input(""))

print("\nChatbot: That's Correct! Let's play a game, tell me a year and I will tell you if it's a leap year or not");

year = int(input())

if (year%4 == 0 and year%100 != 0) or year%400 == 0:

    print("\nChatbot: It's a leap year!")

else:

    print("\nChatbot: It's not a leap year")

print("\nChatbot: Give me two numbers a and b!")

a = int(input(""))

b = int(input(""))

print("\nChatbot: If we do a/b then quotient will be "+str(int(a/b))+" and remainder will be "+str(a%b))

print("\n\n")

Output:

Add a comment
Know the answer?
Add Answer to:
[PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I am trying to solve the following problem using python: Assignment 3: Chatbot A chatbot...

    Hello, I am trying to solve the following problem using python: Assignment 3: Chatbot 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. Here is the scenario: You have decided to start an online website. You are creating a prototype to show investors so you can raise money and launch your website. You should ask the user at least 5...

  • in python 5.23 Login Create a program that prompts the user for a username and password....

    in python 5.23 Login Create a program that prompts the user for a username and password. The correct username should be python and the correct password should be csci 135. See below for example output. (Different messages depending on if user name or password are correct.) Only allow the user to make 3 attempts. Welcome to my secret program! Please enter your username: Trish Please enter your password: Duce Invalid username and password Please enter your username: Trish Please enter...

  • Hello, In Python, I am trying to create a function that will return the domain name...

    Hello, In Python, I am trying to create a function that will return the domain name from any inputted email address. For example, my input of [email protected] would return just the domainname. It needs to be done using regular expressions and the map function. I'm still stuck on trying to get the correct parameters for regular expression and also what is throwing it off. Thank you for your help! I am currently working with a list of different email addresses...

  • Can someone please rewrite this code using a while loop? Please write it in python. #The...

    Can someone please rewrite this code using a while loop? Please write it in python. #The winning number my_number = 12 #variable for the input name user_n = input("Hello! What is your name?") #Ask the user print("Well",user_n,": I am thinking of a number between 1 and 20." + "Take a guess.") user_n = float(input("Take a guess.")) #if statements if user_n == my_number: print("Good job" ,user_n, "You guessed my number!") if user_n > my_number: print("Your guess is high. You lose.") if...

  • IN PYTHON Exercise 4 Build a single chatbot that takes input from the user and behaves...

    IN PYTHON Exercise 4 Build a single chatbot that takes input from the user and behaves in the following way: 1. If the input is a "I feel [..] statement, the chatbot responds by asking "Why do you feel that way"? 2. If the input is a "Can you [predicate] " question, the chatbot responds by saying "Sure, I can [predicatel all day." 3. If the input is a "Did you [predicatel" question, the chatbot responds by saying "No, I...

  • Create a program that will ask for the name, age, address, and favorite food of the...

    Create a program that will ask for the name, age, address, and favorite food of the user. After which, create a calculator with ADD, SUB, MULTI, and DIV. Then the program will display all the user have inputted in bash program ACTIVITY 4: Create a program that will ask for the name, age, address, and favorite food of the user. After which create a calculator with ADD, SUB, MULTI, and DIV. Then the program will display all the user have...

  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number...

    Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...

  • python question Question 1 Write a Python program to play two games. The program should be...

    python question Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...

  • on python i need to code a guessing game. After the player has guessed the random...

    on python i need to code a guessing game. After the player has guessed the random number correctly, prompt the user to enter their name. Record the names in a list along with how many tries it took them to reach the unknown number. Record the score for each name in another list. When the game is quit, show who won with the least amount of tries. this is what i have so far: #Guess The Number HW assignment import...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT