
We are presenting you with one of the shortest and simplest calculator programs in python you could ever found. This calculator will contain the most basic functions you have seen in your life.
We will be creating a calculator that will add, subtract, divide, and multiply two numbers.
We will run the program until we don’t want to exit using a while loop, so that we can calculate as many as calculations we want.
If you want the calculator program in python gui then click here.
First, we will ask the user to choose one of the four basic operations i.e. “Addition“, “Subtraction“, “Multiplication“, and “Division“.
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
We will also give choice to the user so that he can exit the program whenever he wants.
print("5. Exit")
Now, we will store the value entered by the user using the variable “choice“.
choice = int(input("Enter your choice: "))
Now, we will see the code and we will use comments to explain to you this basic Calculator Program In Python.
Calculator Program In Python: Code
# creating while loop
while True:
# printing the available options
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
# asking user to Enter his choice
choice = int(input("Enter your choice: "))
# checking the choice between 1 and 4
if (choice>=1 and choice<=4):
# asking to enter two options
print("Enter two numbers: ")
# accepting first number
num1 = int(input())
# accepting second number
num2 = int(input())
# checking if number is 1
if choice == 1:
# adding
res = num1 + num2
# printing Addition
print("Result = ", res)
# checking if number is 2
elif choice == 2:
# Subtracting
res = num1 - num2
# printing Subtraction
print("Result = ", res)
# checking if number is 3
elif choice == 3:
# Multiplication
res = num1 * num2
# printing Result
print("Result = ", res)
# after checking all 3 choice,
# only one operation left, i.e. for Division
else:
# Division
res = num1 / num2
# printing Result
print("Result = ", res)
# checking if the choice is 5
elif choice == 5:
# if choice is 5, we will exit the program
exit()
# everything, except the five choices is useless
# so, we will print Wrong input..!!
else:
print("Wrong input..!!")Calculator Program In Python: Output
1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter your choice: 1 Enter two numbers: 12 23 Result = 35 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter your choice: 2 Enter two numbers: 23 12 Result = 11 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter your choice: 3 Enter two numbers: 12 23 Result = 276 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter your choice: 4 Enter two numbers: 24 12 Result = 2.0 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter your choice: 5
This progam is very basic level Calculator Program In Python for beginners. But, we can add more choice and operations according to our needs.
Thanks for reading
Keep Learning
If you found something wrong in the article, then please let us know.
Also Read:
- You Can Now Run AI Fully Offline on Your Phone — Google’s Gemma 4 Just Changed EverythingWhat if your smartphone could run a powerful AI assistant without internet, without cloud, and without API costs? That’s now possible. Google recently introduced a new generation of compact AI models designed specifically for on-device use, and they can run entirely offline on consumer phones using the AI Edge Gallery app. This marks a major…
- I Built a 24×7 AI Blogging System for WordPress Using Python (Free) — Full Code InsideIn this article, I will show you how I built a powerful Python-based system that automatically generates and publishes articles to WordPress — completely free and running 24×7. This project handles everything: All you need to do is provide keywords. What This System Actually Does This is not just a script—it’s a complete automation pipeline….
- This Reddit User “Hacked” AI With Simple Tricks… And The Results Are InsaneWhat if you could get dramatically better answers from AI—without any advanced prompting skills, tools, or coding? A recent Reddit post is going viral for exactly this reason. The user claims they’ve been “manipulating” AI models using simple psychological tricks—and surprisingly, the results are much better. Now, this isn’t some technical exploit or hidden feature….
- One “rm -rf” Command Almost Wiped Out $100 Million Worth of Toy Story 2In software, a single command can make or break everything. But in the late 1990s, one mistake at Pixar nearly erased months of work—and potentially $100 million worth of production—on Toy Story 2. This isn’t a myth. It’s a real incident that developers still talk about today. What Actually Happened During production, the team was…
- How to Make Money with ChatGPT in 2026: A Real Guide That Still WorksThere’s a silent thought many people are carrying right now. It doesn’t always get said out loud, but it’s there: “AI has made everything too competitive… maybe it’s too late now.” It feels like everyone is doing something online. Everyone has access to tools like ChatGPT. Content is everywhere. Freelancers are everywhere. Ideas are everywhere….








