Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What is a global variable?
Think about where this variable is defined.
What is a generator in Python?
Consider its memory usage benefits.
What is the advantage of using local variables over global variables?
Think about how Python searches for variable definitions.
True or False: Generators compute values upfront and store them in memory.
Consider how generators handle memory.
Write a Python function that demonstrates the difference in memory usage between a list and a generator for generating Fibonacci numbers up to N.
Use `yield` for the generator.
Create a performance comparison script that uses timeit to evaluate the speed of a built-in function versus a manual loop for computing the sum of a list.
Set up two functions and run them through `timeit`.
4 more questions in this section. Enroll free to practise them all.
Enroll free