IKH

Dictionary comprehension

  • Comprehension concept applicable for dictionaries also.

Example

Python
squares={x:x*x for x in range(1,6)} 
print(squares) 
doubles={x:2*x for x in range(1,6)} 
print(doubles) 

Output

PowerShell
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
{1: 2, 2: 4, 3: 6, 4: 8, 5: 10}

Ungraded Questions

Get ready for an exhilarating evaluation of your understanding! Brace yourself as we dive into the upcoming assessment. Your active participation is key, so make sure to attend and demonstrate your knowledge. Let’s embark on this exciting learning journey together!


Name
Email
Phone