1
+ #Create a class Publisher (name).
2
+ #Derive class Book from Publisher with attributes title and author.
3
+ #Derive class Python from Book with attributes price and no_of_pages.
4
+ #Write a program that displays information about a Python book.
5
+ #Use base class constructor invocation and method overriding.
6
+
7
+ class Publisher ():
8
+
9
+ def __init__ (self ,t ,n ):
10
+ self .__title = t
11
+ self .__author = n
12
+ def display (self ):
13
+ print ("Title =" ,self .__title )
14
+ print ("author =" ,self .__author )
15
+ class Book (Publisher ):
16
+
17
+ def __init__ (self ,t ,n ,p ,np ):
18
+ super ().__init__ (self ,t ,n )
19
+ self .__price = p
20
+ self .__no_of_page = np
21
+
22
+ def display (self ):
23
+ print ("price =" ,self .__price )
24
+ print ("no_of_page =" ,self .__no_of_page )
25
+ class Python (Book ):
26
+ def __init__ (self ,t ,n ,p ,np ):
27
+ self .__title = t
28
+ self .__author = n
29
+ self .__price = p
30
+ self .__no_of_page = np
31
+ def display (self ):
32
+ print ("Title =" ,self .__title )
33
+ print ("author =" ,self .__author )
34
+ print ("price =" ,self .__price )
35
+ print ("no_of_page =" ,self .__no_of_page )
36
+
37
+ obj = Python ("book1" ,"nam1" ,1000 ,100 )
38
+ obj .display ()
39
+
0 commit comments