Changes

Jump to: navigation, search

Rchan sandbox

531 bytes added, 12:03, 3 November 2019
Part 2: Global Scope
print('print() in main on schoolName:',schoolName)
</source>
:* The execution of the script '''lab7i.py''' shown above should give your:<source lang="bash">
[rchan@centos7 lab7]$ python3 lab7i.py
print() in main on schoolName: Seneca
print() in function1 on schoolName: SICT
print() in main on schoolName: Seneca
print() in function2 on schoolName: SSDO
print() in main on schoolName: SSDO
</source>
::Note that the function1() call does not modify the global '''schoolName''' object but function2() does.
Note As the last task for this lab: modify the script above so that it would print the following, by changing only the function1() call does not modify scope of some objects. Save the global program as '''schoolNamelab7i.py''' object but function2() does.:
As an exercise: modify the example above so that it would print the following, by changing only the scope of some objects. Save the program as '''lab7i.py''': <sourcelang="bash">print() in main on schoolName: Senecaprint() in function1 on schoolName: SICTprint() in main on schoolName: SICTprint() in function2 on schoolName: SSDOSICTprint() in main on schoolName: SSDO
</source>
1,760
edits

Navigation menu