I have been trying to make this calculator work but it always says that my choice is invalid. I tried valid numbers and for some reason it doesn't work. Any help would be appreciated. I'm still new to python and to programming in general. Thanks.
#Calculator
print("1.Addition")
print("2.Substraction")
print("3.Multiplication")
print("4.Divison")
#Choose the calculation
Choice=int(input("Enter your choice (1/2/3/4): "))
#Inserting the numbers
Num1=float(input("Insert your first number: "))
Num2=float(input("Insert your second number: "))
if Choice == '1':
ans= Num1 + Num2
print("Your answer is: ",ans)
elif Choice == '2':
ans= Num1 - Num2
print("Your answer is: ",ans)
elif Choice == '3':
ans= Num1*Num2
print("Your answer is: ",ans)
elif Choice == '4':
ans= Num1/Num2
print("Your answer is: ",ans)
else:
print("Invalid choice. ")
Aucun commentaire:
Enregistrer un commentaire