Use Comprehension Make Following Dictionary 0 0 1 1 2 8 3 27 4 64 5 125 6 216 7 343 8 512 Q37093272

Use comprehension to make the following dictionary: 0: 0, 1: 1, 2: 8, 3: 27, 4: 64, 5 125, 6: 216, 7: 343, 8: 512, 9 729

Use comprehension to make the following dictionary: 0: 0, 1: 1, 2: 8, 3: 27, 4: 64, 5 125, 6: 216, 7: 343, 8: 512, 9 729 Show transcribed image text Use comprehension to make the following dictionary: 0: 0, 1: 1, 2: 8, 3: 27, 4: 64, 5 125, 6: 216, 7: 343, 8: 512, 9 729


Solution


d = {x:x**3 for x in range(10)}print(d)

Output:

{0: 0,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.