0% found this document useful (0 votes)
13 views4 pages

Set AcceptFunction

Set_AcceptFunction

Uploaded by

lucabruno955120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Set AcceptFunction

Set_AcceptFunction

Uploaded by

lucabruno955120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

def accept_set(A,Str):

n = int(input("Enter the total no. of student who play %s : "%Str))

for i in range(n) :

x = input("Enter the name of student %d who play %s : "%((i+1),Str))

[Link](x)

print("Set accepted successfully");

def display_set(A,Str):

n = len(A)

if(n == 0) :

print("\nGroup of Students who play %s = { }"%Str)

else :

print("\nGroup of Students who play %s = {"%Str,end=' ')

for i in range(n-1) :

print("%s,"%A[i],end=' ')

print("%s }"%A[n-1]);

def search_set(A,X) :

n = len(A)

for i in range(n):

if(A[i] == X) :

return (1)

return (0)
def Main() :

Group_A = []

Group_B = []

Group_C = []

while True :

print ("\t1 : Accept the Information")

print ("\t2 : Exit")

ch = int(input("Enter your choice : "))

Group_R = []

if (ch == 2):

print ("End of Program")

break

elif (ch==1):

accept_set(Group_A,"Cricket")

accept_set(Group_B,"Badminton")

accept_set(Group_C,"Football")

display_set(Group_A,"Cricket")

display_set(Group_B,"Badminton")

display_set(Group_C,"Football")

else :

print ("Wrong choice entered !! Try again")


Main()

quit()

OUTPUT:
1 : Accept the Information

2 : Exit

Enter your choice : 1

Enter the total no. of student who play Cricket : 3

Enter the name of student 1 who play Cricket : aa

Enter the name of student 2 who play Cricket : bb

Enter the name of student 3 who play Cricket : cc

Set accepted successfully

Enter the total no. of student who play Badminton : 2

Enter the name of student 1 who play Badminton : aa

Enter the name of student 2 who play Badminton : dd

Set accepted successfully

Enter the total no. of student who play Football : 4

Enter the name of student 1 who play Football : aa

Enter the name of student 2 who play Football : bb

Enter the name of student 3 who play Football : cc

Enter the name of student 4 who play Football : dd

Set accepted successfully

Group of Students who play Cricket = { aa, bb, cc }


Group of Students who play Badminton = { aa, dd }

Group of Students who play Football = { aa, bb, cc, dd }

1 : Accept the Information

2 : Exit

Enter your choice : 2

End of Program

You might also like