Set

 Simple program with set

# compare to dictionary set have non repetitive values
set_={ 1,2,3,1}
print(set_)

Output:







program with set methods

set1 = {1, 3, 5, 3}
print(set)

# append set
set1.add(7)
print(set1)

# create a null set
a = set()
print(type(a))

Output:







Program to input user marks and print them

set1 = set()
i=int
i=0
while i < 8:
a = input("enter any desired marks \t")
set1.add(a)
i = i+1
print(set1)

Output:













No comments:

Post a Comment