The program defines a Student class and creates three instances of the class, each representing a different student. It then displays the details of each student using the display_details method. Here's a breakdown of the code:
Here's what the code does:
class Student: def __init__(self, roll_number, name, percent): self.roll_number = roll_number self.name = name self.percent = percent def display_details(self): print("Roll Number :", self.roll_number) print("Name :", self.name) print("Percentage :", self.percent) # Creating objects of the Student class with constructor initialization s1 = Student(501, "Kim", 85.5) s2 = Student(502, "Bob", 78.0) s3 = Student(503, "Tin", 90.3) print("Student 1 Details :") s1.display_details() print("\nStudent 2 Details :") s2.display_details() print("\nStudent 3 Details :") s3.display_details()
Student 1 Details : Roll Number : 501 Name : Kim Percentage : 85.5 Student 2 Details : Roll Number : 502 Name : Bob Percentage : 78.0 Student 3 Details : Roll Number : 503 Name : Tin Percentage : 90.3
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions