Python is the popular language for creating programs.
If you want to make a calculator, then I tell you the basic code to make a calculator.
If you want to get more information about Python language and Python codes then bookmark this blog and read new code and tricks.
Calculator Basic Code
# Calculator
while True:
def add(a,b):
add(a+b)
def subtract(a,b):
subtract(a-b)
def multiply(a,b):
multiply(a*b)
def division(a,b):
division(a/b)
def remainder(a,b):
remainder(a%b)
print("Select Operation")
print("1 Addition")
print("2 Subtraction")
print("3 Multiplication")
print("4 Division")
print("5 Remainder")
print("Enter E or e for Exit")
choice=input("Enter you choice")
if choice=='E' or choice=='e':
break
a=int(input("Enter First Number"))
b=int(input("Enter Second Number"))
if choice=='1':
print(a+b)
elif choice=='2':
print(a-b)
elif choice=='3':
print(a*b)
elif choice=='4':
print(a/b)
elif choice=='5':
print(a%b)
else:
print("Invalid choice")
Output:-
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice1
Enter First Number45
Enter Second Number5
50
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice2
Enter First Number60
Enter Second Number30
30
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice3
Enter First Number25
Enter Second Number25
625
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice4
Enter First Number625
Enter Second Number25
25.0
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice5
Enter First Number55
Enter Second Number2
1
Select Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Remainder
Enter E or e for Exit
Enter you choice
Process finished with exit code 0
Thanx for Reading !! If this post is helpful for you then don't forget to Bookmark it.


0 Comments