Thursday, May 2, 2024

BCA PART B 4. Demonstrate use of Dictionary

 


n = 10

# declare dictionary
numbers = {}

# run loop from 1 to n
for i in range(1, n+1):
numbers[i] = i * i

# print dictionary
print(numbers)

No comments:

Post a Comment