SEP-PYTHON

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 . . .

t

 
  
 PART-B
4.Write a python program to create Simple Class and Object
#--------------------------------------
  
class Student:  
    def __init__(self, name, roll_no, course):
        self.name = name        # Attribute
        self.roll_no = roll_no  # Attribute
        self.course = course    # Attribute
 
    def display_info(self):
        print(f"Student: {self.name} | Roll No: {self.roll_no} | Course: {self.course}")

 
student1 = Student("Aryan", 101, "Computer Science")
student2 = Student("Isha", 102, "Data Science")

 
print("--- Student Records ---")
student1.display_info()
student2.display_info()
 
print(f"\nDirect Access: {student1.name} is enrolled in {student1.course}.")