Skip to content

Commit 3e6431a

Browse files
authored
Update class.py
1 parent 0c28fff commit 3e6431a

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

class.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1-
class Person:
1+
#A simple program to under the concept of class and object in python3
2+
class BookStore:
3+
noOfBooks = 0
4+
5+
def __init__(self, title, author):
6+
self.title = title
7+
self.author = author
8+
BookStore.noOfBooks += 1
9+
10+
def bookInfo(self):
11+
print("Book title:", self.title)
12+
print("Book author:", self.author,"\n")
13+
14+
# Create a virtual book store
15+
b1 = BookStore("Great Expectations", "Charles Dickens")
16+
b2 = BookStore("War and Peace", "Leo Tolstoy")
17+
b3 = BookStore("Middlemarch", "George Eliot")
18+
19+
# call member functions for each object
20+
b1.bookInfo()
21+
b2.bookInfo()
22+
b3.bookInfo()
223

3-
age = 18
24+
print("BookStore.noOfBooks:", BookStore.noOfBooks)
425

5-
def name(self, name):
6-
return list(name)
26+
##OUTPUT :
27+
#Book title: Great Expectations
28+
#Book author: Charles Dickens
29+
30+
#Book title: War and Peace
31+
#Book author: Leo Tolstoy
32+
33+
#Book title: Middlemarch
34+
#Book author: George Eliot
35+
36+
#BookStore.noOfBooks: 3

0 commit comments

Comments
 (0)