Python Program to print student details using single inheritance

In this program, you will learn how to print student details using single inheritance in Python.


class Student:      
   //Statement 

class Test(Student):
   //Statement

Python Program to print student details using single inheritance

Example: How to print student details using single inheritance in Python

class Student:

    def __init__(self):
        self.name = input("Enter your name:")
        self.cname = input("Enter your college name:")
        self.roll = int(input("Enter your roll number:"))


class Test(Student):
    def display(self):
        print("============ Student info is ==========")
        print("Name is : ", self.name)
        print("College Name is:", self.cname)
        print("Roll number is:", self.roll)


obj = Test()
obj.display()

Output:

Enter your name:Xiith
Enter your college name:Xiith34
Enter your roll number:101
============ Student info is ==========
Name is :  Xiith
College Name is: Xiith34
Roll number is: 101