Dictionary
Aim: Implement
a Program to implement a dictionary comprehension.
Algorithm:
1.Start
2.
Create a dictionary
3.Update
existing entry
4.Add
a new entry.
5.Print
the updates.
6.Stop
Program:
dict = {'Name': 'Zara',
'Age': 7, 'Class': 'First'}
dict['Age'] = 8 # update existing entry
dict['School'] =
"DPS School" # Add
new entry
print
"dict['Age']: ", dict['Age']
print
"dict['School']: ", dict['School']
Output:
dict['Age']:
8
dict['School']:
DPS School
0 Comments:
Post a Comment