Skip to content
10,000 Seconds
← All journeys
Coding & web

Learn Python basics by building a simple calculator

Six half-hour sessions built on the official Python tutorial. You'll grow one script step by step until it's a calculator that takes user input, handles mistakes, and keeps running until you quit.

Outcome

A working calculator.py that does + - * / and powers from user input, rejects bad input without crashing, blocks division by zero, and repeats until the user quits.

10,000 sec · 2:46:406 × 27 min 47 sec
  • Every resource is a real public page our team picked. Our server checks the links; if one ever breaks, tell us and we'll replace it.
  • Install Python only from python.org or your computer's official app store, never from a random download site.
  • Phones and Chromebooks without Linux can't run these scripts directly; a free browser-based Python editor can stand in, but setup steps will differ.
  • Decimal results like 0.30000000000000004 are normal computer rounding, not a bug in your code.
  • 10,000 seconds is a structured starting point. It builds a real first result, not guaranteed expertise.

Outline

  1. 1

    Install Python and run your first script

    Python runs on your computer and you can run a .py file from the terminal.

    27:47
  2. 2

    Python as a calculator

    Use every arithmetic operator and store results in variables.

    27:47
  3. 3

    Get numbers from the user

    Ask the user for two numbers and add them correctly.

    27:47
  4. 4

    Choose the operation with if and elif

    Let the user pick + - * or / and get the right answer.

    27:47
  5. 5

    Handle bad input and dividing by zero

    Your calculator asks again instead of crashing on bad input or a zero divisor.

    27:46
  6. 6

    Capstone: build the full calculator

    A finished calculator that handles five operators, bad input, and repeat calculations until you quit.

    27:46

Capstone

Your working calculator

A command-line calculator in Python that takes two numbers and an operator, handles bad input and division by zero, and repeats until you quit, plus one feature you added yourself.

Sources