-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path141 prog.py
64 lines (48 loc) · 1.32 KB
/
141 prog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
print("enter title name")
title=input()
print("enter publisher")
publisher=input()
print("enter price")
price=int(input())
print("enter title name")
title1=input()
print("enter publisher")
publisher1=input()
print("enter price")
price1=int(input())
class book:
def __init__(self,t,p,pr):
self.t=0
self.p=0
self.pr=0
def set(self,t,p,pr):
self.t=t
self.p=p
self.pr=pr
def __lt__(self,other):
if (self.pr<other.pr):
return "price of book 1 is less"
else:
return "price of book 2 is less"
def __gt__(self,other):
if (self.pr>other.pr):
return "price of book 1 is greater"
else:
return "price of book 2 is greater"
def __eq__(self,other):
if (self.pr==other.pr):
return "price of books are equal"
else:
return "price of books are not equal"
def display(self):
print("title is:",self.t)
print("publisher name is:",self.p)
obj1=book(title,publisher,price)
obj1.set(title,publisher,price)
obj2=book(title1,publisher1,price1)
obj2.set(title1,publisher1,price1)
obj1.display()
obj2.display()
print(obj1<obj2)
print(obj1>obj2)
print(obj1==obj2)