inner Class python
inner Class python
Source code :-
class Student:
def __init__(self, name, rollno):
self.name = name
self.rollno = rollno
self.lap = self.Laptop()
def show(self):
return (self.name, self.rollno)
self.lap.show()
class Laptop:
def __init__(self):
self.brand = "HP"
self.cpu = "i5"
self.ram = 8
def show(self):
print(self.brand, self.cpu, self.ram)
s1 = Student('Shreyash', 23)
# s2 = Student('Shubham', 25)
print(s1.show())
lap1 = Student.Laptop()
lap1.show()
Output
('Shreyash', 23) HP i5 8
Post a Comment