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. 😎
- Get the first number from the user (
int(input(...))) - Get the second number
- Get the operation:
+,-,*or/(this one is text — noint()needed!) - Use
if/elifto check the operation and compute the matching result - 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
Section titled “Mission”Calculator
+25 XP ✓ CompletedFollow 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 →