if op == 0:
print("Thank you for using our calculator!")
if op == 1:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first + second
print("1. Addition")
print(result)
if op == 2:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first - second
print("2. Subtraction")
print(result)
if op == 3:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first / second
print("3. Multiplication")
print(result)
if op == 4:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first * second
print("4. Division")
print(result)
Question:
1. In this program, you are going to create a with getter and setter.
while(True):
print("Enter 1 for Addition ")
print("Enter 2 for Subtraction ")
print("Enter 3 for Multiplication ")
print("Enter 3 for Division ")
print("Enter 0 for exit")
op = int(input("Enter your choice : "))
if op == 0:
print("Thank you for using our calculator!")
break
if op == 1:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first + second
print("1. Addition")
print(result)
if op == 2:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first - second
print("2. Subtraction")
print(result)
if op == 3:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first / second
print("3. Multiplication")
print(result)
if op == 4:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first * second
print("4. Division")
print(result)
Comments
Leave a comment