The Python Calculator

Step 2 – Get the number inputs

Code helper image

Next we need to get the user to enter the two numbers.

  1. We'll use input statements for this, and we'll use two variables to store the values.
  2. I'm going to call my variables number1 and number2 because that sort of makes sense to me.
  3. Remember, Python thinks anything you enter is a string (words), so we have to convert the input to numbers. We do this by adding the int command. This time I'm going to include this on the input lines. This just saves some space.
  4. Leave a gap between the two lines. We'll fill this in in a minute
  5. Run your code to check it works (Run > Run Module)

Python will ask you to save your code each time you make a change and then run it. Just say OK each time.

You should be able to enter the two numbers without a problem, but the program will then stop.