Python exercises for ages 10+

Create a calculator

Part 1

Write a program that asks the user for two numbers, then outputs the sum of these numbers. For example, if the user inputs 5 and 4, the output should be 9.

Part 2

Extend your program to additionally ask the user for a basic arithmetic operator. The output should then be the result of the operation on the two numbers. For example, if the user inputs 5, 4, and -, the output should be 1.

Extra

Consider what the program does when you give it an unknown operator or other bad input. Then extend your program to accept three more uncommon arithmetic operators:

Name Symbol
Modulus %
Quotient //
Exponent **

See if you can reverse engineer what these operators do by testing your program with different inputs to determine a pattern.