0
4.1kviews
Define a function which can print a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys.
1 Answer
0
859views

Solution:

Write a Python script to print a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys.

Flowchart:

enter image description here

Python Code:

d=dict()

for x in range(1,21):

d[x]=x**2

print(d)

Output:

{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, …

Create a free account to keep reading this post.

and 4 others joined a min ago.

Please log in to add an answer.