-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-A SET.PY
33 lines (26 loc) · 1 KB
/
5-A SET.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
#5-A) To implement real-time/technical applications using Sets
# Set manipulation
CSE = {"PQT", "ADC", "SE", "DPSD", "DS", "OOP"}
IT = {"OS", "PQT", "DS", "SE", "OOP", "SS"}
print("CSE =",CSE)
print("IT =",IT)
# 1. Names of subjects in CSE
print("Subjects in CSE : ")
print(", ".join(CSE))
# 2. Names of subjects in IT
print("Subjects in IT : ")
print(", ".join(IT))
# 3. Names of subjects in CSE only
print("Names of subjects in CSE only : ", CSE.difference(IT))
# 4. Names of subjects in IT only
print("Names of subjects in IT only : ", IT.difference(CSE))
# 5. Names of subjects in both CSE and IT
CommonSubjects = CSE.intersection(IT)
print("Names of common subjects in CSE and IT :",CommonSubjects)
# 6. Names of subjects for either CSE or IT, but not in both
UniqueSubjects = CSE.symmetric_difference(IT)
print("Names of subjects for either CSE or IT, but not in both = ",
UniqueSubjects)
# 7. Names of all subjects.
Allsub=CSE.union(IT)
print("Names of all subjects : ", Allsub)