# why this code no work?

print ('MathBot: Would you like me to do a math problem?')

if input(': ').lower() == 'no' or 'nope' or 'no thanks' or 'nah' or 'no way dude':

try:

print('ok')

exit()

if input(': ').lower() == 'yes' or 'yeah' or 'yes please' or 'sure' or 'yeah dude':

try:

hi = input('/,-,+,x: ')

num1 = input('number 1: ')

num2 = input('number 2: ')

if hi == '+':

print(float(num1) + float(num2))

if hi == '-':

print(float(num1) - float(num2))

if hi == '/':

print(float(num1) / float(num2))

if hi == 'x':

print(float(num1) * float(num2))

except ValueError:

print('Error')

+1 vote
answered May 14, 2021 by (160 points)

print ('MathBot: Would you like me to do a math problem?')
if input(': ').lower() == 'no' or 'nope' or 'no thanks' or 'nah' or 'no way dude':
print('ok')
exit()
elif input(': ').lower() == 'yes' or 'yeah' or 'yes please' or 'sure' or 'yeah dude':
hi = input('/,-,+,x: ')
num1 = input('number 1: ')
num2 = input('number 2: ')
if hi == '+':
print(float(num1) + float(num2))
elif hi == '-':
print(float(num1) - float(num2))
elif hi == '/':
print(float(num1) / float(num2))
elif hi == 'x':
print(float(num1) * float(num2))

This one works...

commented May 19, 2021 by (120 points)
I can help. Depends what math. I can do addition, subtraction, multiplication, and division but thats it :(
commented May 19, 2021 by (120 points)
I can only do it in C++ though