Lab No 15 Ha
Lab No 15 Ha
In [12]: """
Write a code in python to make calculator
"""
while True:
print("A : Addition")
print("S : Subtraction")
print("M : Multiplication")
print("D : Division")
print("E : Exit")
choice = input("Enter your choice: ")
if choice == "a" or choice == "A":
print("Addition")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a + b
print(str(a) + " + " + str(b) + " = " + str(answer))
elif choice == "a" or choice == "s":
print("substraction")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a - b
print(str(a) + " - " + str(b) + " = " + str(answer))
elif choice == "m" or choice == "M":
print("Multiplication")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a + b
print(str(a) + " * " + str(b) + " = " + str(answer))
elif choice == "d" or choice =="D":
print("Division")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a/b
print(str(a) + " / " + str(b) + " = " + str(answer))
elif choice == "e" or choice== "E":
print("End of program")
break
A : Addition
S : Subtraction
M : Multiplication
D : Division
E : Exit
Enter your choice: a
Addition
Enter First Number: 100
Enter Second Number: 50
100 + 50 = 150
A : Addition
S : Subtraction
M : Multiplication
D : Division
E : Exit
Enter your choice: e
End of program
Conclusion: