Hi everyone,
I recently started learning how Python works and thought I would set up a simple calculator which asks for three inputs:
1. The first number
2. Operator
3. The second number
This is my code:
5
*
5
= 10.0
What am I doing wrong?
I really hope I am not filling up the forum with too simple stuff seeing what others are discussing in these forums. If that is the case please feel free to delete. I am just here to learn!
Kind regards
I recently started learning how Python works and thought I would set up a simple calculator which asks for three inputs:
1. The first number
2. Operator
3. The second number
This is my code:
num1 = float(input ("Insert number: ")) operator = input ("What operation do you want to do: ") num2 = float(input ("And the second number: ")) if operator == "+" or "Plus" or "plus": print(num1 + num2) elif operator == "minus" or "Minus" or "-": print(num1 - num2) elif operator == "Multiplication" or "multiplication" or "*": print(num1 * num2) elif operator == "/" or "divide" or "Divide": print(num1 / num2) else: print("Sorry, operator not identified, please try again: ")It does not give a Syntax Error, but whenever I insert the two numbers along with an operator it only adds up the numbers. Example:
5
*
5
= 10.0
What am I doing wrong?
I really hope I am not filling up the forum with too simple stuff seeing what others are discussing in these forums. If that is the case please feel free to delete. I am just here to learn!
Kind regards