-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.py
More file actions
141 lines (91 loc) · 2.76 KB
/
set.py
File metadata and controls
141 lines (91 loc) · 2.76 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#Library Book Managment
total_books = {'san','ramar','berlin','chicago','tom riddle'}
available_books= total_books.copy()
issued_books = {'saa','maa','san','tom riddle'}
def add_books() :
book = input("Enter books to add : ")
available_books.add(book)
print("The book is added",book)
print("No of books : ",available_books)
def remove_books() :
book = input("Enter books to remove : ")
if book in available_books :
available_books.discard(book)
print("The book is removed",book)
print("No of books : ",available_books)
else :
print("Invalid book")
def issue_books() :
books = input("Enter book you want : " )
if books in available_books :
issued_books.add(books)
available_books.remove(books)
print("Book issued successfully : ")
else :
print("Not available")
def returnn_books() :
returnn=input("Enter book to return : ")
if returnn in issued_books :
available_books.add(returnn)
issued_books.discard(returnn)
print("Book returned successfully")
else :
print("Book not returned")
def view_books():
print("Available_books : ", available_books)
print("issued_books : ", issued_books)
print("All_books : ",available_books|issued_books)
def compare_books() :
book = input("Enter book to compare : ")
if book in available_books & total_books :
print(" Unique books : ",book)
else :
print("No Unique books ")
if book in available_books| total_books:
print("Union of Books : ",available_books |total_books)
def setrelation() :
super = issued_books.issuperset( total_books)
print("The superset is : ",super)
subset = total_books.issubset( issued_books)
print("The subset is : ",subset)
dis = available_books.isdisjoint(issued_books)
print("The intersection is : ",dis)
def clear_copy() :
a = total_books.copy()
b = issued_books.copy()
z = issued_books.clear()
print("The copy of total books ",a)
print("The copy of issued books ",b)
print("The issued book ",z)
while True:
print("1. Add Book")
print("2. Remove Book")
print("3. Issue Book")
print("4. Return Book")
print("5. View Books")
print("6. Compare Books")
print("7. Set Relations")
print("8. Clear and Copy Sets")
print("9. Exit")
choice = input("Enter your choice : ")
if choice == '1':
add_books()
elif choice == '2':
remove_books()
elif choice == '3':
issue_books()
elif choice == '4':
returnn_books()
elif choice == '5':
view_books()
elif choice == '6':
compare_books()
elif choice == '7':
setrelation()
elif choice == '8':
clear_copy()
elif choice == '9':
print("Exiting ....")
break
else:
print("Invalid choice")