MATH0011 video 4: local and global variables

Опубликовано: 20 Март 2026
на канале: Matthew Towers
117
2

The definition of local and global variables. Local variables aren't available outside the body of the function they belong to. Using global variables inside a function definition can lead to unexpected behaviour - the same function called with the same argument can give different results at different times. Example to show that Python treats an assignment inside a function body as creating a new local variable, not changing a global variable.

If you want to more about Python variable scope, read this: https://realpython.com/python-scope-l...