Set Data-type in python
# SET DATA TYPE : THIS DATA TYPE IS ONLY SAVE UNIQE VALUES
# myset = set()
# print(type(myset))
# normal set is able to store on value, if you want to enter
# more then one value you have to enter a dictionary in set
# ... set({}) like this
myset = set({1,2,3,4,5,6})
# WE CAN ONLY ADD DIFFERENT VALUE NOT SIMMILAR IN THE SET, if we
# add more then one simiural value it enter only one value
myset.add(7)
myset.add(7)
myset.remove(1)
print(myset)
cars_set={"Benze","BMW","Ford","Civic","Civic"}
cars_set1 = ["Benze","BMW","Ford","Civic","Civic"]
cars_set2 = ("Benze","BMW","Ford","Civic","Civic")
cars_set3={"Benze":"18model","BMW":"8model","Civic":"19model"}
print(type(cars_set)) # set
print(type(cars_set1))# list
print(type(cars_set2))# tuple
print(type(cars_set3))# Dictionary
Comments
Post a Comment