8000 Create ClassComposition · Aksh2020/complete-python-course@af9adcf · GitHub
[go: up one dir, main page]

Skip to content

Commit af9adcf

Browse files
authored
Create ClassComposition
1 parent d86ca09 commit af9adcf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

course_contents/ClassComposition

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class BookShelf:
2+
def __init__(self, *books):
3+
self.books=books
4+
5+
def __repr__(self):
6+
return f"<Bookshelf with {len(self.books)} books>"
7+
8+
9+
class Book:
10+
def __init__(self,name):
11+
self.name=name
12+
13+
14+
def __repr__(self):
15+
return f"book {self.name}"
16+
17+
18+
book1 = Book("Harry Potter")
19+
book2 = Book("101 Python")
20+
21+
bookshelf=BookShelf(book1,book2)
22+
print(bookshelf)

0 commit comments

Comments
 (0)
0