The Python Calculator

Step 4 – Do some maths

Now we can do some maths.

I'm just doing the first part of this for now.

We need to use selection to decide what to do next.

    Code helper image
  1. This code goes at the bottom of your program
  2. I'm going to start with addition, so if the user entered an "A" I want to add the two numbers together. This uses an if statement.
  3. The if line needs to have a colon (:) at the end
  4. We need to use two equals signs to check if the two things are the same. Make sure you use  == in the if line
  5. Check your indents!
  6. Add the print line underneath so that the answer is displayed
  7. Run your code to check it works (Run > Run Module)

Test with an A entered. This should add the two numbers together.

If you enter S, M or D nothing will happen yet.