Step-by-step Explanation
✅ Part 1: Dictionary Comprehension
-
This is a dictionary comprehension.
range(3) produces: 0, 1, 2
-
For each i, it maps:
-
Key → i
-
Value → i**2 (i squared)
-
So the dictionary x becomes:
Which results in:
✅ Part 2: Accessing a Key
x[2] retrieves the value associated with key 2, which is 4.
✅ Final Output


0 Comments:
Post a Comment