Let's write a simple calculator!
It will read 3 lines:
- the first number
- the second number
- the arithmetic operation.
Numbers are floats!
The output is the result of the following: first_number operation second_number.
Operations are: +, -, /, *, mod, pow, div.
mod — modulo operation, i.e. the remainder of the division first_number % second_number,
pow — exponentiation, the first number will be the base and the second — the power: first_number ** second_number,
div — integer division first_number // second_number.
Note that if the second number is 0 and you want to perform any of the operations /, mod, or div, the calculator should say "Division by 0!"
If you have too many
elif branches, you may consider another approach, for example, break the code into smaller functions. Since you don't know how to do it yet, ignore the code style error about the number of elif branches.