Skip to content

Project 1: Calculator

This module is different: no lessons — projects. Each page is a real program that ties together everything you’ve learned. Nobody hands you finished code — you get a plan, the rest is on you. 😎

  1. Get the first number from the user (int(input(...)))
  2. Get the second number
  3. Get the operation: +, -, * or / (this one is text — no int() needed!)
  4. Use if/elif to check the operation and compute the matching result
  5. Print the result nicely with an f-string: 8 * 2 = 16

Bonus idea (optional): for an operation it doesn’t recognize, have the else branch say “I don’t know that operation.”

Mission

Calculator

+25 XP

Follow the plan and finish the calculator. (A test scenario is ready in the inputs: 8, 2, * — the answer should be 16.) If you like, change the inputs and try other operations too!

Inputs (for input())

One value per line — read in order by input().

Output
 

Next project: a pro version of the “Guess the number” game — this time the program gives you hints. Continue →