This Python program defines three classes: Details, Student, and Staff. These classes are used to collect and display information about students and staff members. Here's an explanation of the program:
This program demonstrates the use of class inheritance, where the Student and Staff classes inherit common attributes and methods from the Details class. It showcases how you can collect and display specific information for different types of objects (students and staff) while reusing and customizing common functionality provided by the parent class.
class Details: def __init__(self): self.idn = 0 self.name = "" self.gender = "" def setDetails(self): self.idn = input("Enter the ID Number : ") self.name = input("Enter the Name : ") self.gender = input("Enter the Gender : ") def showDetails(self): print("ID : ",self.idn) print("Name : ",self.name) print("Gender : ",self.gender) class Student(Details): def __init__(self): self.total = 0 self.per = 0 def setStudent(self): self.setDetails() self.total = int(input("Enter the Total Mark : ")) self.per = float(input("Enter the Percentage : ")) def showStudent(self): self.showDetails() print("Total : ",self.total) print("Percentage : ",self.per) class Staff(Details): def __init__(self): self.depart = "" self.salary = "" def setStaff(self): self.setDetails() self.depart = input("Enter the Department : ") self.salary = float(input("Enter the Salary : ")) def showStaff(self): self.showDetails() print("Department : ",self.depart) print("Salary : ",self.salary) print("Student Details : ") stu = Student() stu.setStudent() stu.showStudent() print("\nStaff Details : ") stf = Staff() stf.setStaff() stf.showStaff()
Student Details : Enter the ID Number : 103 Enter the Name : Mithra Enter the Gender : Female Enter the Total Mark : 350 Enter the Percentage : 70.0 ID : 103 Name : Mithra Gender : Female Total : 350 Percentage : 70.0 Staff Details : Enter the ID Number : ST012 Enter the Name : Ram Kumar Enter the Gender : Male Enter the Department : Computer Science Enter the Salary : 45000 ID : ST012 Name : Ram Kumar Gender : Male Department : Computer Science Salary : 45000.0
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions