Professional Documents
Culture Documents
Practical 2
Practical 2
class Calculator:
def addition(self):
a = int(input("Enter first number:"))
b = int(input("Enter Second number:"))
print(a + b)
def subtraction(self):
a = int(input("Enter first number:"))
b = int(input("Enter Second number:"))
print(a - b)
def multiplication(self):
a = int(input("Enter first number:"))
b = int(input("Enter Second number:"))
print(a * b)
def division(self):
a = int(input("Enter first number:"))
b = int(input("Enter Second number:"))
print(a / b)
obj = Calculator()
choice = 1
while choice != 0:
print("1. ADDITION")
print("2. SUBTRACTION")
print("3. MULTIPLICATION")
print("4. DIVISION")
print("5. EXIT")
choice = int(input("Enter your choice:"))
if choice == 1:
print(obj.addition())
elif choice == 2:
print(obj.subtraction())
elif choice == 3:
print(obj.multiplication())
elif choice == 4:
print(obj.division())
elif choice == 5:
break
else:
print("Invalid choice")
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
5. EXIT
Enter your choice:1
Enter first number:20
Enter Second number:30
50
None
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
5. EXIT
Enter your choice:5
Enter a number: 8
The factorial of 8 is 40320
Enter a number: 16
the number is even