Quiz
Python Variable Scope Quiz
Free beginner quiz on Python variable scope: 15 questions on local and global variables, the global and nonlocal keywords, and nested functions.
10 results
Quiz
Free beginner quiz on Python variable scope: 15 questions on local and global variables, the global and nonlocal keywords, and nested functions.
Example
The nonlocal keyword gives access to variables in the enclosing function.
Challenge
…launches_today inside the function as local or global in scope . Modify. Pass the count into the function as a second parameter, return the new count, and store it at each call, without global . It…
Challenge
refuel() assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write…
Example
The global keyword allows modifying a global variable inside a function.
Example
Local variables exist only inside functions. Global ones are accessible everywhere.
Article Python Fundamentals
…your first def to return values, default parameters and scope, with runnable examples, common mistakes and six practice projects.
Quiz
…on def, return, arguments, default values, *args, scope and docstrings. Instant answers.
Quiz
…on naming, assignment, data types, type conversion and scope, with instant answers.
Quiz
…keyword arguments, returning several values and variable scope How it works 20 questions: 15 with one correct answer, 5 where you select every correct answer After each question you see the correct…