Python Online Compiler

Program for Max Number using NoReturn type with NoParameters
Functions


def maxnum():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))
    if(x>y):
        print("x is Max")
    else:
        print("y is Max")


#fuction Calling
maxnum()
         

OUTPUT: Enter x Value12 Enter y Value24 y is Max

Program for Max Number using NoReturn type with Parameters

def maxnum(x,y):
   
    if(x>y):
        print("x is Max")
    else:
        print("y is Max")


#fuction Calling
x=int(input("Enter x Value"))
y=int(input("Enter y Value"))
maxnum(x,y)
         

OUTPUT: Enter x Value12 Enter y Value24 y is Max

Program for Max Number using Return type with NoParameters

def maxnum():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))

    if(x>y):
        return "x is Max"
    else:
        return "y is Max"


#fuction Calling
print(maxnum())
         
OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using Return type with Parameters

def maxnum(x,y):
    if(x>y):
        return "x is Max"
    else:
        return "y is Max"


#fuction Calling
x=int(input("Enter x Value"))
y=int(input("Enter y Value"))
print(maxnum(x,y))
         
OUTPUT: Enter x Value12 Enter y Value24 y is Max

Constructor Program
Data abstruction


class Maxnum:
    def __init__(self):
        x=int(input("Enter x Value"))
        y=int(input("Enter y Value"))
        if(x>y):
            print("x is max")
        else:
            print("y is max")

m=Maxnum()
OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using NoReturn type with NoParameters With NoParameters Constructor
Constructor


class Maxnum:
    def __init__(self):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self):
        if(self.x>self.y):
            print("x is max")
        else:
            print("y is max")

m=Maxnum()
m.max()

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using NoReturn type with Parameters With NoParametarized Constructor


class Maxnum:
    def __init__(self):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self,p,q):
        if(self.x>self.y):
            print("x is max")
        else:
            print("y is max")

m=Maxnum()
m.max(200,100)

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using Return type with NoParameters With NoParametarized Constructor


class Maxnum:
    def __init__(self):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self):
        if(self.x>self.y):
            return "x is max"
        else:
            return "y is max"

m=Maxnum()
print(m.max())
OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using Return type with Parameters With NoParametarized Constructor


class Maxnum:
    def __init__(self):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self,p,q):
        if(self.x>self.y):
            return "x is max"
        else:
            return "y is max"

m=Maxnum()
print(m.max(200,100))

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using NoReturn type with NoParameters With Parametarized Constructor


class Maxnum:
    def __init__(self,a,b):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self):
        if(self.x>self.y):
            print("x is max")
        else:
            print("y is max")

m=Maxnum(2000,1000)
m.max()

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using NoReturn type with Parameters With Parametarized Constructor
                      

class Maxnum:
    def __init__(self,a,b):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self,p,q):
        if(self.x>self.y):
            print("x is max")
        else:
            print("y is max")

m=Maxnum(2000,1000)
m.max(200,100)

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using Return type with NoParameters With Parametarized Constructor

class Maxnum:
    def __init__(self,a,b):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self):
        if(self.x>self.y):
            return "x is max"
        else:
            return "y is max"

m=Maxnum(2000,1000)
print(m.max())

OUTPUT: Enter x Value12 Enter y Value24 y is max

Program for Max Number using Return type with Parameters With Parametarized Constructor


class Maxnum:
    def __init__(self,a,b):
        self.x=int(input("Enter x Value"))
        self.y=int(input("Enter y Value"))
    def max(self,p,q):
        if(self.x>self.y):
            return "x is max"
        else:
            return "y is max"

m=Maxnum(2000,1000)
print(m.max(200,100))
OUTPUT: Enter x Value12 Enter y Value24 y is max

Single Inheritance
Inheritance

class Parent:
    def  __init__(self):
        self.name=input("Enter  Name")
        self.location=input("Enter Location")
        self.gender=input("Enter Gender")
class Child(Parent):
    def __init__(self):
        Parent.__init__(self)
        self.marks=int(input("Enter Marks"))
    def display_Details(self):
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Marks is",self.marks)

#Create Object For Child Class
c=Child()
c.display_Details()
        
        

OUTPUT: Enter Namesateesh Enter Locationchennai Enter Gendermale Enter Marks24 Your Name is sateesh Your Location is chennai Your Gender is male Your Marks is 24

MultiLevel Inheritance

class Parent:
    def  __init__(self):
        self.name=input("Enter  Name")
        self.location=input("Enter Location")
        self.gender=input("Enter Gender")
class Child(Parent):
    def  __init__(self):
        Parent.__init__(self)
        self.Address=input("Enter  Address")
    
class Child1(Child):
    def __init__(self):
        Child.__init__(self)
        self.marks=int(input("Enter Marks"))
    def display_Details(self):
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Marks is",self.marks)

#Create Object For Child Class
c=Child1()
c.display_Details()
        
        

OUTPUT: Enter NameSateesh Enter LocationChennai Enter GenderMale Enter AddressChennai Enter Marks24 Your Name is Sateesh Your Location is Chennai Your Gender is Male Your Marks is 24

Hierarchical inheritance


class Parent:
    def  __init__(self):
        self.name=input("Enter  Name")
        self.location=input("Enter Location")
        self.gender=input("Enter Gender")
        self.Address=input("Enter  Address")
           
class Student(Parent):
    def __init__(self):
        Parent.__init__(self)
        self.marks=int(input("Enter Marks"))
    def display_Details(self):
        print("Strudent Details Are ......................")
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Marks is",self.marks)
        print(" ")
class Faculty(Parent):
    def __init__(self):
        Parent.__init__(self)
        self.salary=int(input("Enter Salary"))
    def display_Details(self):
        print("Faculty Details Are ......................")
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Salary is",self.salary)
        print(" ")

class Principal(Parent):
    def __init__(self):
        Parent.__init__(self)
        self.salary=int(input("Enter Salary"))
    def display_Details(self):
        print("Principal Details Are ......................")
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Salary is",self.salary)
        print(" ")


#Create Objects For Child Classes
s=Student()
s.display_Details()
f=Faculty()
f.display_Details()
p=Principal()
p.display_Details()
        
        

OUTPUT: Enter NameSateesh Enter LocationChennai Enter GenderMale Enter AddressChennai Enter Marks24 Strudent Details Are ...................... Your Name is Sateesh Your Location is Chennai Your Gender is Male Your Marks is 24 Enter NameVarshini Enter LocationChennai Enter GenderFemale Enter AddressChennai Enter Salary24000 Faculty Details Are ...................... Your Name is Varshini Your Location is Chennai Your Gender is Female Your Salary is 24000 Enter NamePriya Enter LocationCHennai Enter GenderFemale Enter AddressChennai Enter Salary240000 Principal Details Are ...................... Your Name is Priya Your Location is Chennai Your Gender is Female Your Salary is 240000

Multiple inheritance

class Parent1:
    def  __init__(self):
        self.name=input("Enter  Name")
        self.location=input("Enter Location")
        self.gender=input("Enter Gender")
        
           
class Parent2:
    def __init__(self):
        self.Address=input("Enter  Address")
   
class Child(Parent1,Parent2):
    def __init__(self):
        Parent1.__init__(self)
        Parent2.__init__(self)
        self.salary=int(input("Enter Salary"))
    def display_Details(self):
       
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Salary is",self.salary)
        print(" ")


#Create Object For Child Class
p=Child()
p.display_Details()
        
OUTPUT: Enter NameVarshini Enter LocationChennai Enter GenderFemale Enter AddressChennai Enter Salary24000 Your Name is Varshini Your Location is Chennai Your Gender is Female Your Salary is 24000

Hybrid Inheritance

class Parent1:
    def  __init__(self):
        self.name=input("Enter  Name")
        self.location=input("Enter Location")
        self.gender=input("Enter Gender")
        
           
class Parent2:
    def __init__(self):
        self.address=input("Enter  Address")
   
class Child(Parent1,Parent2):
    def __init__(self):
        Parent1.__init__(self)
        Parent2.__init__(self)
        self.salary=int(input("Enter Salary"))
    def display_Details(self):
        print("Child 1 Details")
        print("Your Name is",self.name)
        print("Your Location is",self.location)
        print("Your Gender is",self.gender)
        print("Your Salary is",self.salary)
        print("Your Address is",self.address)
        print(" ")
class Child1(Parent2):
    def __init__(self):
        self.name=input("Enter name")
        Parent2.__init__(self)
    def  display_Details(self):
         print("Child 2 Details")
         print("Your Name is",self.name)
         print("Your Address is",self.address)
        

#Create Object For Child Class
p=Child()
p.display_Details()
c=Child1()
c.display_Details()
OUTPUT: Enter Name Sateesh Enter Location Chennai Enter Gender Male Enter Address Chennai Enter Salary 24000 Child 1 Details Your Name is Sateesh Your Location is Chennai Your Gender is Male Your Salary is 24000 Your Address is Chennai Enter name Varshini Enter Address Chennai Child 2 Details Your Name is Varshini Your Address is Chennai