May 2018
Intermediate to advanced
380 pages
9h 37m
English
To illustrate scope, we will create nested functions, where a function is defined and then called within an enclosing function:
>>> def first_funct(): ... x = 1 ... print(x) ... def second_funct(): ... x = 2 ... print(x) ... second_funct() ...
>>> first_funct() 1 2
>>> second_funct() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'second_funct' is not defined
>>> import math