1. Program to print capitals of countries from a dictionary
dict1 = {'India': 'NewDelhi', 'UK': 'London', 'Japan': 'Tokyo'}
print("Capitals of :", dict1.keys(), " are", dict1.values())
2. Consider the dictionary:
contestants={1:"Anita Singh", 2:"Amber Sharma", 3:"Chetan Gupta", 4:"Falguni Nathani"}
Now write a Python script
i. to change the name of contestant 3 to "Chetan Garg" .
ii. to add two new contestants, whose names have to be entered by the user.
iii. to display the values of all even numbered keys.
iv. to display the first name of all the contestants.
3. WAP to create a record of students with their names and marks in 5 subjects using a dictionary. Also display the records.
4. Write a Python script to generate and print a dictionary that contains a number as the key and its square as the value in the form(x:x*x). The dictionary should contain n elements where n is input by the user.
Example if n = 4, then the dictionary should look like :
{1: 1, 2: 4, 3: 9, 4: 16}
5. Write a Python script to search for a given value in a Dictionary.
6. WAP to create a dictionary storing records of n players. The records should have name and scores in 2 matches. Display the data showing clearly the names and scores of each player.
7. Referring to the program in question 2, write a Python script to calculate and display the average marks of each student in the class.