FDS 1
u ={1,2,3,4,5,7,8,9,10,12}
a =[1,2,3,4,5]
b =[2,3,5,7,9]
c =[3,5,8,10,12]
print("Student who play cricket :",a)
print("Student who play badminton:",b)
print("Student who play football",c)
"""Both cricket and badminton"""
def intersection(a,b):
result =[]
for students in a :
if students in b :
result.append(students)
return result
#print("Students who played both are:",result)
print("Student who play both cricket and badminton are:",intersection(a,b))
def union(a,b):
result2 =b.copy()
for students in a:
if not students in b:
result2.append(students)
return result2
#print ("Students who played both altoghether:",result2)
print("Student who play cricket and badminton altoghether are:",union(a,b))
'''Either cricket or badminton but not both'''
r1={1,2,3,4,5,7,9}
r2={2,3,5}
r3= r1-r2
print("Students who play either cricket or badminton but not both are : ",r3)
'''Neither cricket nor badminton'''
r4= u-r2
print ("Students who play neither cricket nor badminton:",r4)
def union(a,c):
r5 =c.copy()
for students in a:
if not students in c:
r5.append(students)
return r5
#print ("Students who played both altoghether:",r5)
print("Student who play cricket and football altoghether are:",union(a,c))
'''Cricket and football but not badminton'''
r6={1,2,3,4,5,8,10,12}
r7= u-r6
print ("Students who play cricket and football but not badminton are :",r7)