Python program to Create Dictionary of keys from 1 to n and values are square of keys

d=dict()
for x in range(1,15):
    d[x]=x**2
print(d)

OUTPUT:

{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196}

Sharing Is Caring

Leave a Comment