Simple calculator program in python

Introduction 


Now a days python is one of the most widely used programming  language in the world and today I will be sharing a simple calculator program in python (beginner level). This program will help you to understand basic syntax of python and will give you a basic idea to use if and else condition statement.I have provided the code below you go through the code.

Code


print("Select Opertion") 
print("1)Add") 
print("2)Subtract") 
print("3)Multiply") 
print("1)Divide") 
choice = input("Enter your choice(1/2/3/4):") 
num1 = int(input("Enter first number:")) #accepting first number 
num2 = int(input("Enter second number:")) #accepting second number 
if choice == "1": 
 print(num1+num2) 
elif choice == "2":
 print(num1-num2) 
elif choice == "3": 
 print(num1*num2) 
elif choice == "4": 
 print(num1/num2) 
else: print("Invalid operation entered")

Output



Conclusion

By the end of this post you must have learned how to make a basic calculator in python and if you have any queries related this program or post you can comment below.
Previous
Next Post »

1 comments:

Click here for comments
123456789
admin
October 23, 2019 at 4:38 PM ×

Here you will learn what is important, it gives you a link to an interesting web page: 160 lbs to kg

Congrats bro 123456789 you got PERTAMAX...! hehehehe...
Reply
avatar