bot_name : str = 'Bob'
print(f'Hello I\'m {bot_name} ! How can I assist you today?')
while True:
user_input: str = input('You : ').lower()
if user_input in ['hi', 'hello']:
print(f'{bot_name}: Hi there ! how can i help you')
elif user_input in ['bye', 'see you']:
print(f'{bot_name}: Good bye have a great day')
elif user_input in ['+', 'add']:
print(f'{bot_name}: Sure ! let do some addition ! Please enter two number')
try:
num1: float = float(input('FirstNumber :' ))
num2: float = float(input('SecondNumber :' ))
print(f'{bot_name}: The sum is {num1+num2 }')
except ValueError:
print(f'{bot_name}: Oopss! That doesn\'t a valid number. Try again')
else:
print(f'{bot_name}: I\'m sorry, I don\'t understand that. Please try again.')
0 Response to "Python 14, simple project"
Posting Komentar