0Pricing
Coding for Kids · Lesson

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

  1. Getting Two Numbers
  2. Doing the Math
  3. Choosing an Operation
  4. Showing the Answer
← Back to Coding for Kids