Scope Rules Select All That Apply

Select all statements below that are true about scope and name binding in Python functions.

A

If a name is assigned anywhere inside a function body, every reference to that name inside the function is treated as local, even on lines that would execute before the assignment

B

Reading a global variable inside a function requires a global statement, but reassigning one does not

C

A nonlocal statement raises a SyntaxError at compile time if no enclosing function defines that name; it does not fall back to the module's global scope

D

Using global x inside a function and then assigning to x creates x at module scope even if no module-level x existed before the function ran