01/08/2026
๐งฎ Build a Calculator Application Using Python โ A Beginner's Guide
A calculator is one of the first projects every Python beginner should build. It helps you understand how to accept user input, perform mathematical operations, use conditional statements, and write clean, organized code.
Step 1: Display the Calculator Menu
Start by showing users the available operations.
print("Simple Calculator")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
This gives users a clear menu to choose from.
---
Step 2: Get User Input
Ask the user to enter two numbers and select an operation.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
choice = input("Choose operation (1/2/3/4): ")
Using "float()" allows both whole numbers and decimal numbers.
Example:
- First Number: "25"
- Second Number: "5"
- Operation: "4"
---
Step 3: Perform the Calculation
Use "if", "elif", and "else" statements to determine which calculation to perform.
if choice == "1":
print("Result:", num1 + num2)
elif choice == "2":
print("Result:", num1 - num2)
elif choice == "3":
print("Result:", num1 * num2)
elif choice == "4":
if num2 != 0:
print("Result:", num1 / num2)
else:
print("Error: Division by zero is not allowed.")
else:
print("Invalid choice.")
---
Example Output
Simple Calculator
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter first number: 20
Enter second number: 4
Choose operation (1/2/3/4): 3
Result: 80
---
What You'll Learn
โ
Variables and data types
โ
Accepting user input
โ
Arithmetic operators ("+", "-", "*", "/")
โ
Conditional statements ("if", "elif", "else")
โ
Error handling (preventing division by zero)
โ
Writing simple, reusable Python programs
---
Challenge Yourself
Improve your calculator by adding:
- Power ("**")
- Modulus ("%")
- Square root
- Percentage calculations
- A loop so the calculator keeps running until the user chooses to exit
Building projects like this strengthens your programming skills and prepares you for larger software applications.
๐ Want to Learn More?
Join our DPN (Diploma in Programming & Networking) Program at:
ETC Elevate Training Center
๐ Panorama Hotel Plaza, Airport Road, Juba
๐ +211 918 643 483
Learn Python programming, MySQL databases, Computer Networking, and practical software development through hands-on training designed for beginners and future professionals.