0% found this document useful (0 votes)
24 views

Labwork-5.ipynb - Colaboratory

The document demonstrates how to use dictionaries in Python. It shows creating dictionaries with keys and values, accessing values using get and pop methods, and obtaining keys and values. Dictionaries L1 and person are defined with keys and values, person["Occupation"] is updated, values are printed using get and pop, and keys and values are obtained into lists.

Uploaded by

Sandip Solanki
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Labwork-5.ipynb - Colaboratory

The document demonstrates how to use dictionaries in Python. It shows creating dictionaries with keys and values, accessing values using get and pop methods, and obtaining keys and values. Dictionaries L1 and person are defined with keys and values, person["Occupation"] is updated, values are printed using get and pop, and keys and values are obtained into lists.

Uploaded by

Sandip Solanki
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#1

L1 ={}

L1["A"]=4

L1["B"]=5

L1["C"]=318

L1["D"]=339

L1["E"]=320

print(L1)

{'A': 4, 'B': 5, 'C': 318, 'D': 339, 'E': 320}

#2

person = {"name ": "Jessa" , "country":"usa","telephone":"1178","Occupation": "programmer"
person["Occupation"] = "farmer"

print(person)

{'name ': 'Jessa', 'country': 'usa', 'telephone': '1178', 'Occupation': 'farmer

person = {"name":"Jessa","country":"usa","telephone":"1178","Occupation":"programmer"}

for i in person.keys():

print("\n")

print(i)

File "<ipython-input-11-893316053e2d>", line 3

print("\n")

IndentationError: expected an indented block

SEARCH STACK OVERFLOW

person = {"name": "Jessa" , "country":"usa","telephone":"1178","Occupation": "programmer"}
print(person.get("telephone"))

print(person.pop("name"))

1178

Jessa

person = {"name": "Jessa" , "country":"usa","telephone":"1178","Occupation": "programmer"}
print("keys=" ,list(person.keys()))

print("values=" ,list(person.values()))

keys= ['name', 'country', 'telephone', 'Occupation']

values= ['Jessa', 'usa', '1178', 'programmer']

keys= ['name', 'country', 'telephone', 'Occupation']

values= ['Jessa', 'usa', '1178', 'programmer']

You might also like