Professional Documents
Culture Documents
Python 2.3
Python 2.3
WORKSHEET- 2.3
Student Name: Harsh Raj UID: 21BCS8426
Branch: CSE Section/Group: 719/A
Semester: 4th Date of Performance: 11/04/23
Subject Name: Programming in Python Lab Subject Code: 21CSP-259
2. Source Code:
1. a.
d1={'Name':'Harsh','UID':'21BCS8426', 'Section':719}
'''
print(d1['Name']) #METHOD- 1
print(d1['UID']) #given key exists in dictionary or not.
print(d1['Section'])
print(d1['UIDS'])
'''
print(d1.get('Name'))
print(d1.get('UID')) #METHOD-2
print(d1.get('Section'))
print(d1.get('UIDS')) #given key exists in dictionary or not.
b.
d1={'Name':'Harsh','UID':'21BCS8426', 'Section':719}
d1['Section'] = '719/A'
print(d1)
c.
d1={'Name':'Harsh','UID':'21BCS8426', 'Section':719}
del d1['Name']
print(d1)
2.
d1={'Name':'Harsh','UID':'21BCS8426', 'Section':719}
for i in d1.keys():
print(d1[i])
3. a.
b.
c.
1. a.
b.
c.
2.
3. a.
b.
c.