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