I dont understand a quiz. Can anyone explain me this... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I dont understand a quiz. Can anyone explain me this...

https://code.sololearn.com/c42P8b9tWe1b/?ref=app

24th Oct 2019, 1:31 PM
Deepak Rajbhar
Deepak Rajbhar - avatar
2 Answers
+ 4
It is a dictionary comprehension. For the numbers in range(1, 10, 3) - this works out at just the numbers 1, 4 and 7 - the dictionary is created with these numbers (x) as its keys, and x**2 (x squared or x*x) as its values. So key 1 corresponds to the value 1, key 4 has value 16 and key 7 (which is the one in the code) has value 49. So see the whole dictionary, you can add print(d) at the end.
24th Oct 2019, 1:40 PM
Russ
Russ - avatar
+ 2
Thank You very much Sir. I was confused at the key part
24th Oct 2019, 1:43 PM
Deepak Rajbhar
Deepak Rajbhar - avatar