MISC
Mutability
is the ability of a variable to be changed.immutable
variable, the variable is created again from scratch.Immutable
variables include:
Output
4463277792
4463277952
scope
.Scope
defines where a variable can be read and altered.Scope
is determined by where a variable is originally defined.scope.py
Output
Patient Name: Alice Smith
Traceback (most recent call last):
File "/scope.py", line 6, in <module>
print(patient_name)
^^^^^^^^^^^^
NameError: name 'patient_name' is not defined.
global
keyword.global
allows you to reassign any variable.global
if you are only updating (eg adding elements) mutable variables (eg lists and dictionaries).global.py
Output
Patient Name: Alice Smith
Alice Smith