Friday, 17 December 2021

Python-Slip25-b-Write a Python script to Create a Class which Performs Basic Calculator Operation

 Write a Python script to Create a Class which Performs Basic Calculator Operation

class Calculator:

def addition(self):

print(a + b)

 def subtraction(self):

print(a - b)

def multiplication(self):

print(a * b)

def division(self):

print(a / b)

 a = int(input("Enter FIRST number:"))

b = int(input("Enter SECOND number:"))

obj = Calculator()

choice = 1

while choice != 0:

print("1. ADDITION")

print("2. SUBTRACTION")

print("3. MULTIPLICATION")

print("4. DIVISION")

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())

else:

print("Invalid choice")