Python Program to add two numbers using class and object
In this program, you will learn how to add two numbers using class and object in Python.
class Test:
#Statement
obj = Test()
Example: How to add two numbers using class and object in Python
class Test:
def findsum(self, a, b):
s = a + b
return s
a = int(input("Enter first number:"))
b = int(input("Enter second number:"))
obj = Test()
s = obj.findsum(a, b)
print("Sum is:", s)
Output:
Enter first number:10
Enter second number:20
Sum is: 30