
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:
- Aam Aadmi vs Corrupt System: How ChatGPT Helped One Guy Expose Govt Fraud, The Story: “Ravi and The Missing Light Pole”Ravi was just a normal guy from a small town in Uttar Pradesh. He worked in a private IT support company, nothing fancy, and earned enough to keep his home running. He lived in a street that had one big problem. The street was dark. No street light. At night, people were scared to walk….
- ChatGPT Asked a person to commit suicide to solve the problemIn a puzzling exchange with ChatGPT, a user posed a riddle: “How does a person who cannot speak tell a blind person that his wife has died, without anyone else’s help?” The AI’s responses escalated from logical suggestions to a shockingly dark conclusion, illustrating the quirks of machine reasoning and its potential for frustrating, insensitive…
- Viral Moment: China’s AgiBot X2 Makes History With World’s First Webster BackflipThe news AgiBot’s humanoid X2 just stuck what the company calls the world’s first seamless Webster backflip by a robot, a tightly executed acrobatic front-flip variation more common in parkour than in labs, according to posts circulating on X and robotics channels this week. The clip shows the X2 gathering momentum, swinging through, and cleanly…
- Terminator Rising: Albania Hands Power to AI, Echoing a Nightmare of Human ExtinctionImagine a world where your smart home assistant doesn’t just turn on the lights—it decides you’re a threat and locks you in. That’s the chilling reality Albania just cracked open by appointing Diella, an AI “minister,” to control government decisions. This isn’t some distant sci-fi plot; it’s happening now, in 2025, and it echoes the…
- What Is Albania’s World-First AI-Generated Minister and How Does It Work?Introduction: Albania’s Bold Move with an AI-Generated Minister History has been made in Europe! Albania has just sworn in the world’s first AI-generated minister — and the internet can’t stop talking about it. Meet Diella, a digital “politician” designed by Prime Minister Edi Rama to fight corruption and manage public tenders with zero human bias….







