Python Tutorial for Beginners [DataTypes] | Complete set and frozen set tutorial |
Автор: harshal mishra
Загружено: 2020-04-24
Просмотров: 47
Описание:
Playlist : • Py-Pie Python Tutorial
'''
Sets in Python
'''
x = {}
print(type(x))
Sets are unordered.
x = {1,2,3}
y = {3,2,1}
print(x==y)
Set elements are unique. Duplicate elements are not allowed.
x = {1,1,2,3,3,5}
print(x)
A set itself may be modified, but the elements contained in the set must be of an immutable type.
x = {1,2,3}
x[1] = 4
#'set' object does not support item assignment
x ={1,2,3}
#add()
x.add(4)
print(x)
#remove()
x.remove(3)
print(x)
#pop()
x.pop()
print(x)
#clear()
x.clear()
print(x)
#len()
x = {1,2,3}
print(len(x))
x = {1,2,3}
y = list(x)
print(y)
print(1 in x)
print(33 in x)
Frozen Set
x = frozenset({1,2,3})
print(x)
x.add(4)
#frozenset' object has no attribute 'add'
Повторяем попытку...
![Python Tutorial for Beginners [DataTypes] | Complete set and frozen set tutorial |](https://ricktube.ru/thumbnail/fwvVVy5IXDw/hq720.jpg)
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: