Join the conversation
Ur teaching method is osm sir
Reply
# Data structures# List (mutable , ordered , Accept duplicate , Access by index)list = ["orange" , "apple" , "banana" , "banana"]
print(list)
print(list[2])list[2] = "papita"
print(list)
print(list[2])# Tuples (immutable , ordered , Accept duplicate , Access by index)
tuple = (1 , 2 , 3 , 4 , 5 , 6 , 2)
print(tuple)
print(tuple[6])# Sets (Muteable , unordered , no duplicate , not access by index)set = {1 , 3 , 5 ,7}
print(set)
set.add(13)
print(set)# Dictionaries(Muteable , ordered , just allow values duplicate not key , accessed by key)dict = {"babar" : 56 ,
"Shaheen" : 10 ,
"Nawaz" : 10 ,
}dict["Nawaz"] = 68
print(dict)
Reply
list are ordered and set is unordered, list has index and set has not, set remove duplicate automatically and list accept duplicates
Reply
it is good
Reply
easy way hy sir thank you very much khosh rahain aamin
Reply
Python has three mutable data structures: lists, dictionaries, and sets. Immutable data structures, on the other hand, are those that we cannot modify after their creation. The only basic built-in immutable data structure in Python is a tuple
Reply
yes
Reply
TypeError: 'tuple' object does not support item assignment sir i find this eror what can i do
Reply
sir why did the tuple value not change?
Reply
bcz tuple mostly ap waha use karty hu jaha koi apki chezy change karsaky some kind of sceruity hope i clear your concept
car={"brand":"ford","model":"mustang","year":1995}
print(car)
print(car["brand"])
print('brand: {}'.format(car["brand"]))#Using the format() Method:
print('Brand: ' + car["brand"])#Using String Concatenation:
print(f'Brand: {car["brand"]}')#Using f-Strings (Python 3.6+):
print(car.keys())
print(car.values())
Reply