COMP 206 Lecture Notes - Lecture 30: Module File, Local Variable, Global Variable

7 views2 pages

Document Summary

Multiple choice program writing (3 programs, one in each language) Assignment to a variable can either declare a new variable or modify the value of a(cid:374) existi(cid:374)g o(cid:374)e: this depe(cid:374)ds o(cid:374) (cid:858)s(cid:272)ope(cid:859) Ule of thu(cid:373)(cid:271): (cid:858)use (cid:373)ost lo(cid:272)al s(cid:272)ope possi(cid:271)le(cid:859) Efere(cid:374)(cid:272)es to varia(cid:271)les (cid:373)ust (cid:272)o(cid:373)e after assig(cid:374)(cid:373)e(cid:374)t(cid:894)(cid:862)(cid:271)i(cid:374)di(cid:374)g(cid:863)(cid:895) a(cid:374)d look-up values using same rules. Local- assigned in any way in that function. Enclosing function locals- name in local scope of any/all enclosing functions from inner to outer. Global- assigned at the top level of a module file, outside of a function (or declared as global within a def. Built-in- name preassigned in the built-in names module. Longer allowed to use the global variable anywhere in the function, even before the local variable is declared. Seriously, better practice is to just use different names for local and global variables. All instances of a class can share the same variable. Important things to consider, like security as well as ability for code to.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents