Search the courses, subjects, tracks, games and features, or jump straight to a page.
5 cards from this section. Quick, good the night before a test.
What is a global variable?
Think about where the variable is defined.
What does the global keyword do?
It starts with a 'g' and lets you change a variable outside the function.
What keyword do you use to modify a global variable inside a function?
Remember its scope and where it's defined.
True or False: Nonlocal variables are defined outside the function.
Consider the relationship of nested functions.
Create a small Python program that uses both global and nonlocal variables. Explain how they function within different scopes.
Structure it such that each variable's value changes based on the function used.
Explain a real-world application where controlling variable scope with global and nonlocal could resolve a complex issue.
Consider how user inputs might be global events while handling them privately in specific cases.
6 more questions in this section. Enroll free to practise them all.
Enroll free