KEMBAR78
Practical 17.py | PDF
0% found this document useful (0 votes)
34 views1 page

Practical 17.py

The document provides a Python program that defines a 'Student' class with a constructor and a method to display student information. It creates four student objects with different attributes and calls the display method to print their details. The output format is structured to show each student's name, age, and course clearly.

Uploaded by

shrutimanval104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Practical 17.py

The document provides a Python program that defines a 'Student' class with a constructor and a method to display student information. It creates four student objects with different attributes and calls the display method to print their details. The output format is structured to show each student's name, age, and course clearly.

Uploaded by

shrutimanval104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

PRACTICAL 17

Python program to perform the following operations:


1. Creating a Class with the method
2. Creating Objects of class
3. Accessing method using object

class Student:
def __init__(self, name, age, course):
self.name = name
self.age = age
self.course = course

def display_info(self):
print(f"Student Name: {self.name}")
print(f"Age: {self.age}")
print(f"Course: {self.course}")
print("-" * 30)

student1 = Student("Shruti", 18, "Computer Engineering")


student2 = Student("Anvi", 16, "Information Technology")
student3 = Student("Manthan", 21, "Mechanical Engineering")
student4 = Student("Shriya", 19, "ENTC")

print("Student Details:\n" + "=" * 30)


student1.display_info()
student2.display_info()
student3.display_info()
student4.display_info()

OUTPUT:

You might also like