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 Test(Student):
      def display(self):
          //statement

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

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.