Week - Chapter 16 -Python3.5- local variables and global variables scope

PCJ # # 
# Dazhong defined subroutines variable is local, at the beginning of the program given variable as global variables
# scoped global variables for the entire program, local variable scope only given variable subroutine
# To want to get the result of program execution, you can use the return statement returns the results
# School = "Oldboy .edu"
# DEF cheng_name (name):
#, Ltd. Free Join School #global into a global variable, but it is not recommended to use this way, do not use, Do not use
= "MAGE School" School #
# Print ( "the before Chang", name, School)
#
# cheng_name ( "PCJ")
# Print (School)
#
# # previously defined. True then define global variables in a function. This usage, with the need to be dismissed.
DEF the Test # ():
#, Ltd. Free Join name
# name = "LDY"
# the Test ()
# Print (name)
#
# # ----------------------- -----------------------------------
# names = [ "PCJ", "LDY", "the Test" , "sex"


Print # (names)
#
# test2 ()
# Print (names) on the outside, when printing, name [0] is changed

name = "PCJ"
DEF Test3 ():
name = "uppercase the PCJ"
Print ( "--- -: ", name)
Test3 ()
Print (name) # print here or lowercase PCJ

# string, integer, can not be changed locally, and did not take effect. Lists, dictionaries can be changed

Guess you like

Origin www.cnblogs.com/pcjbk/p/10990079.html