Question 13 of 14intermediate🔧 ApplyLong Answer6 marks

Write a program to input your friends' names and their Phone Numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:

(a)

Display the name and phone number of all your friends

(b)

Add a new key-value pair in this dictionary and display the modified dictionary

(c)

Delete a particular friend from the dictionary

(d)

Modify the phone number of an existing friend

(e)

Check if a friend is present in the dictionary or not

(f)

Display the dictionary in sorted order of names

Explanation

This program demonstrates all dictionary operations as per NCERT Class 11 syllabus. The program uses concepts from Program 10-6 for creating dictionaries using input, and Program 10-5 for dictionary operations. Key operations include: (a) using a for loop with keys() to iterate and display all items, (b) adding new entries using assignment operator, (c) using del statement to remove items as shown in context, (d) modifying values by reassigning to existing keys, (e) using 'in' operator to check membership, and (f) using sorted() function to display keys in alphabetical order. The 'in' operator checks if a key exists in the dictionary, which is a standard dictionary operation mentioned in Table 10.2.