Python Data Types (Lists, Tuples, Sets, Dictionaries)

Опубликовано: 27 Январь 2025
на канале: Shantanu Mukherjee
49
1

#List - ordered and changeable (Mutable), square brackets:
lists = ['Banana','Guava','Papaya']
#lists.append("orange")
#lists.remove("Guava")
#print(lists)

#Tuples - ordered and unchangeable (Immutable), round brackets.
tuples = ('Banana','Guava','Papaya')
#print(tuples)

#Sets - unordered, unchangeable*, and unindexed, curly brackets.
sets = {'Red','Yellow','Green','Blue'}
sets.add("orange")
sets.remove("Green")
#print(sets)

#Dictionary - Store data in key: value, Python 3.7, dictionaries are ordered. Python 3.6 and before, it is unordered.
#Dictionary items are ordered, changeable, and does not allow duplicates.

dict = {
"brand": "Hundai",
"model": "SantroZip",
"color": "Black",
"year": 2003
}
dict['wheels']='Four'
dict.pop("color")
print(dict)