Speaking of global variables and local variables today, the foreign teacher said that global variables are like stars in Hollywood and everyone knows. Local variables must be declared before they can be used. Otherwise, people do not know.
# The function, Jennifer is local
Def God ();
Global Jennifer
Jennifer = 'pretty'
# Main program, always global, Hollywood becomes famous, and everybody knows
God ()
Print Jennifer
The output result is: Pretty
# The function, Jennifer is local
Def God ();
Global Jennifer
Jennifer = 'pretty'
# Main program, always global, Hollywood becomes famous, and everybody knows
Jennifer = 'beautiful'
God ()
The output result is: Beautiful
Do you know why ?? Because Jennifer is a global variable, all subsequent local variables are invalid... Only the preceding ones are recognized.
By the way, the teacher also said the types of various variables .....
>>> Number = 5
> FL = 4.3
>>> Sentence = 'you have smelly boots'
>>> B = false
>>> Type (number)
<Type 'int'>
>>> Type (FL)
<Type 'float'>
>>> Type (sentence)
<Type 'str'>
But I have a question?
>>> 2.34
2.3399999999999999
How can 2.34 be 2.3399999999999999 ??
Humbly ask for advice from uncles, sisters, and uncles.