Calculator Program in Python || Single Inheritance || Python


In this we are going to see a basic program of calculator using single inheritance in Python Programming Language.



class Calculator():
    def __init__(self,a,b):
        print("Welcome to Calculator")
        self.a = a
        self.b = b
    def add(self):
        c = self.a + self.b
        return c
    def subtract(self):
        c = self.a - self.b
        return c
    def divide(self):
        c = self.a / self.b
        return c
    def multiply(self):
        c = self.a * self.b
        return c

class Number(Calculator):
    def __init__(self,a,b):
        super().__init__(a,b)
    def end(self):
        print("End")

n = Number(6,5)
print("Addition :",n.add())
print("Substraction :",n.subtract())
print("Division :",n.divide())
print("Multiplication :",n.multiply())
n.end()

# Coded By Dhiraj Shelke


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post