Page 278 - CTS - CSA TP - Volume 2
P. 278
COMPUTER SOFTWARE APPLICATION - CITS
Accessing Values:
Modifying a Dictionary:
Adding New Key-Value Pairs:
Iterating Through a Dictionary:
Removing Key-Value Pairs:
Useful Methods:
• keys(): Returns a list of all keys.
• values(): Returns a list of all values.
• items(): Returns a list of key-value pairs as tuples.
TASK 1 : Basic Dictionary
# Creating a basic dictionary
student = {
‘name’: ‘SreeHari’,
‘age’: 20,
263
CITS : IT & ITES - Computer Software Application - Exercise 128