You are on page 1of 4

Practical No:- 5

Aim : -
Software used: - Python

Question1 – create a dictionary


Implementation: -
d1={1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava"}
print(d1)
Output: -

Question 2 –
Implementation: -
d1={1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava"}
print(d1[4])
Output: -

Question 3 –
Implementation: -
d1={'fruits':{1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava"},'vegetables':{
1:"potato",2:"broccoli",3:"carrot",4:"spinach"}}
print(d1['fruits'][3])
Output: -

Question 4 –
Implementation: -
d1={'fruits':{1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava",3:"banana"},'v
egetables':{1:"potato",2:"broccoli",3:"carrot",4:"spinach"}}
print(d1['fruits'][3])
Output: -

Question 5 –
Implementation: -
d1={'fruits':{1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava",3:"banana"},'v
egetables':{1:"potato",2:"broccoli",3:"carrot",4:"spinach"}}
print (d1)
Output: -

Question 6 –
Implementation: -
person = {
"first_name": "abc",
"last_name": "xyz",
"age": 19,
"city": "LKJ"
}

print("First Name:", person["first_name"])


print("Last Name:", person["last_name"])
print("Age:", person["age"])
print("City:", person["city"])

Output: -

Question 7 –
Implementation: -
d1={1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava"}
print(d1.popitem())

Output: -
Question 8 –
Implementation: -
d1={1:"apple",2:"orange",3:"mango",4:"kiwi",5:"guava"}
print(d1)

del d1
print(d1)
Output: -

You might also like