4. Write a python program where the key value in a dictionary are between 3 and 20, and dictionary values are square of corresponding key number which are provided in the following output. Note that the for loop is expected to be used for this exercise.
The output is:
Expected Answer:
{3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196,
15: 225, 16: 256, 17: 289, 18: 324, 19: 361, 20: 400}
Sample Answer:
empty_d=dict() for i in range(3,21): empty_d[i]=i**2 print(empty_d)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)