def chatbot():
print("--------Welcome to Chatbot-------\n")
while(True):
s = input()#reading input
l = s.split#spliting at space
if(l[0]=="I" and l[1] == "feel"):#mathcing frist two words and
displaying corresponding output
print("Why do you feel that way?")
elif(l[0]=="Can" and l[1] == "you"):
i=2
k=""
while(i<len(l)):
k=k+l[i]+" "
i+=1
print("Sure, I can ",k," all day")
elif(l[0]=="Did" and l[1] == "you"):
i=2
k=""
while(i<len(l)):
k=k+l[i]+" "
i+=1
print("No, I didn't ",k)
elif(s.lower()=="quit"):
break
else:
print("That's interesting. What else is on your mind?")
chatbot()
//PLS give a thumbs up if you find this helpful, its helps me alot, thanks
output:
--------Welcome to Chatbot-------
I feel you are great
Why do you feel that way?
Can you sing
Sure, I can sing all day
Did you do
No, I didn't do
you are great
That's interesting. What else is on your mind?
quit
![1▼ def chatbot(): print(-Welcome to Chatbot--n while(True): s inpu ()#reading input 1 s. split#spliting at space if(1[ojー1 and 1[1] -= feel ): #mathcinq 4. frist two words and displaying print(Why do you feel that way?) i-2 while(i< (1)): elif(1[0]--can and 1[1] you); -- 9 1+-1 print (Sure, I can ,k, all day) if (1[0]Did and 1[1]you): 4. 6 while(i〈lei (1)): 9 1+-1 print (No, I didnt ,k) break print(Thats interesting. What else is on your mind?) elif(s.lower)quit): else: 6 chatbot()](http://img.homeworklib.com/questions/0cde2bd0-45b7-11ec-b99c-8d988ea6ac6c.png?x-oss-process=image/resize,w_560)
IN PYTHON Exercise 4 Build a single chatbot that takes input from the user and behaves...
[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...
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...
For this lab, modify the python code below so it will continuously be asking user for inputs to calculate the interest earned until the user enters number 0 (zero) in principle. Once the user enters any number less or equal to 0 in principle, the program will end. here is my code: # Programming Exercise 3-14 # Local variables p = 0.0 r = 0.0 n = 0.0 t = 0.0 loop = True while loop: p = float(input('\nEnter the...
This is Python
The program should accept input from the user as either 7-digit
phone number or 10-digit. If the user enters 7 characters, the
program should automatically add "512" to the beginning of the
phone number as the default area code. Dash (hyphen) characters do
not count in input character count, but must not be random. If the
user enters dashes the total character count must not exceed
12.
The program should not crash if the user enters invalid...
Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...
Homework 3: Input Validation 1 Objectives control structures console-based user input using Scanner class writing complete programs using two classes: client and supplier 2 User Interface Specification This is a console-based I/O program. Display should go to System.out (print or println) and the program will get user input using the Scanner class. The flow of execution should be as follows: When the program starts, display a one-line introduction to the user Display a menu with 5 options 1. validate zip...
[Using Python] I need my code given below to loop the user input, so that you are asked to input without it stopping after 4 inputs. Code: #A program that converts a hexadecimal number to its decimal value #Define function for hexadecimal to decimal def hexToDec(hexi): result = 0 #For loop to test input for correct values for char in hexi: if 'A' <= char <= 'F' or 'a' <= char <= 'f': if 'a' <= char <= 'f': result...
need help with python program
The objectives of this lab assignment are as follows: . Input data from user Perform several different calculations Implement conditional logic in loop • Implement logic in functions Output information to user Skills Required To properly complete this assignment, you will need to apply the following skills: . Read string input from the console and convert input to required numeric data-types Understand how to use the Python Modulo Operator Understand the if / elif /...
In the original flashcard problem, a user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. A sample session might run as follows: Enter s to show a flashcard and q to quit: s Define: word1 Press return to see the definition definition1 Enter s to show a flashcard...
PYTHON I need some basic python homework help! Write a program that prompts the user to enter a date (day, month, and year). Your program will print out the day of the week for that date. You do not need to validate the input. That means you can assume: the year will be entered as a four-digit number in the range 1900 through 2100 inclusive. the month will be one of the strings "January", "February", . . ., "December". the...