Python Tutorial for Beginners [DataTypes] | Complete set and frozen set tutorial |

Publicado el: 24 abril 2020
en el canal de: harshal mishra
48
3

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'


En esta página del sitio puede ver el video en línea Python Tutorial for Beginners [DataTypes] | Complete set and frozen set tutorial | de Duración hora minuto segunda en buena calidad , que subió el usuario harshal mishra 24 abril 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 48 veces y le gustó 3 a los espectadores. Disfruta viendo!