Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What will happen if you try to modify a global variable without the global keyword inside a function?
Think of the scope limitations of variables.
Write a simple program using a global variable and modifying it in a function.
Use the variable outside the function definition.
What does the global keyword do in Python?
Think about variable scope and accessibility.
True or False? Using global variables can lead to unpredictable outcomes.
Reflect on the chart of variable scope.
Write a Python program that uses multiple functions to increment a global counter. Show how the counter changes after each function call.
Demonstrate the counters changing state as functions are called.
Describe a scenario where multiple functions modify the same global variable. What risks does this pose and how can they be mitigated?
Reflect on common game development scenarios and share best practices.
5 more questions in this section. Enroll free to practise them all.
Enroll free