Day 010 of the 100 Days of Python challenge builds a command-line calculator for addition, subtraction, multiplication, and division.

Project Overview

Each arithmetic operation has its own function. A dictionary maps an operator symbol to the matching function:

operations = {
    "+": addition,
    "-": subtraction,
    "*": multiplication,
    "/": division,
}

This lets the calculator choose and call an operation without a long chain of conditional statements. The get_number() function repeatedly asks for input until it can convert the response to a float.

After calculating a result, the user can continue with that answer or start a new calculation. The loop maintains the current value for chained operations such as 10 + 5 * 2 as separate interactive steps.

What This Project Teaches

Day 010 combines functions, return values, dictionaries, function references, loops, exception handling, and interactive state. The operation dictionary is particularly useful because adding another operator only requires a new function and mapping entry.

The project is intentionally simple and does not implement mathematical precedence. Each operation is performed in the order selected by the user.

Running the Project

cd 100daysofpython/day010
python main.py

The project imports its logo from the folder’s art.py file. View the Day 010 source code on GitHub.