Q-1.Write a Python script to sort (ascending and descending) a dictionary by value.
Q-2.Write a Python script to generate and print a dictionary that contains a number (between 1 and n) in the form (x, x*x).
Sample Dictionary ( n = 5) :
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Sample Dictionary ( n = 5) :
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Q-3.Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are the square of the keys.
Q-4.Write a Python script to merge two Python dictionaries.
Q-5.Write a Python program to sum all the items in a dictionary.
Q-6.Write a Python program to multiply all the items in a dictionary.
Q-7.Write a Python program to get the key, value and item in a dictionary.
Q-8. Write a Python program to access dictionary key's element by index.
Expected Output:
physics
math
chemistry
Expected Output:
physics
math
chemistry
Q-9.car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print the value of the "model" key of the car dictionary.
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print the value of the "model" key of the car dictionary.
Q-10.car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
Change the "year" value from 1964 to 2020.
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
Change the "year" value from 1964 to 2020.