Local and global variables

x = 5; def f(): x = 3; f(); print(x) → 5

You can also choose a level by clicking its number.

About the course

Description
An assignment inside a function creates a local variable – the global one changes only with the global statement
More information
Short programs in Python – what they calculate and what they print.
Sample question
x = 5; def f(): x = 3; f(); print(x) → 5
Author
Jiří Preisler
Version
1.0