Choosing an Operation
Pick with if.
Let the User Choose! 🎛️
Hi captain! 🧑✈️ A real calculator lets YOU pick what to do: add, subtract, multiply, or divide! 🎛️
To do that, we use the magic word if! Let's learn it!
print('What math should I do? ➕➖✖️➗')Asking for a Choice ❓
First, we ask the user which operation they want. We save their answer in a box called choice. ❓
choice = input('Type + or - or * or /: ')
print('You chose', choice)All lessons in this course
- Getting Two Numbers
- Doing the Math
- Choosing an Operation
- Showing the Answer