Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the animation interval to 100 milliseconds.
Matplotlib
ani = FuncAnimation(fig, update, frames=10, interval=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using interval values too large or too small causing animation to be too slow or too fast.
Confusing interval with frames count.
✗ Incorrect
The interval parameter controls the delay between frames in milliseconds. Setting it to 100 means 0.1 seconds between frames.
2fill in blank
mediumComplete the code to set the number of frames to 20.
Matplotlib
ani = FuncAnimation(fig, update, frames=[1], interval=100)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting frames too low causing short animation.
Confusing frames with interval.
✗ Incorrect
The frames parameter controls how many frames the animation will have. Setting it to 20 means the update function will be called 20 times.
3fill in blank
hardFix the error in the code to correctly set frames as a range from 0 to 9.
Matplotlib
ani = FuncAnimation(fig, update, frames=[1], interval=100)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer directly instead of an iterable.
Using list(10) which causes an error.
✗ Incorrect
Frames can be an iterable like range(10) to generate frames from 0 to 9.
4fill in blank
hardFill both blanks to create an animation with frames from 0 to 14 and interval of 50 milliseconds.
Matplotlib
ani = FuncAnimation(fig, update, frames=[1], interval=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong range causing fewer frames.
Setting interval too high or too low.
✗ Incorrect
range(15) creates frames from 0 to 14, and interval=50 sets 50 milliseconds delay between frames.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps frame number to its square, only for frames less than 10.
Matplotlib
squares = { [1]: [2] for [1] in range(15) if [1] [3] 10 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and loop variable.
Using '>' instead of '<' causing empty dictionary.
✗ Incorrect
We use 'frame' as the key, 'frame**2' as the value, and filter frames less than 10 with '<'.