Build a Simple Calculator Using Python

March 3, 20261 minute read

mustaf hersi farah

mustaf hersi farah

Instructor

Build a Simple Calculator Using Python

💡 What You’ll Build

A calculator that adds, subtracts, multiplies, and divides.

print("Simple Calculator")

num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

operation = input("Choose operation (+, -, *, /): ")

if operation == "+":
    print("Result:", num1 + num2)
elif operation == "-":
    print("Result:", num1 - num2)
elif operation == "*":
    print("Result:", num1 * num2)
elif operation == "/":
    if num2 != 0:
        print("Result:", num1 / num2)
    else:
        print("Cannot divide by zero!")
else:
    print("Invalid operation")

© 2026 Softcamper. All rights reserved.