Python Functions: Local vs. Global variables
Terms in this set (13)
A variable declared in the main code is a ______ variable.
A variable declared in a function is a ________ variable.
A parameter is a ________ variable.
Global and local variables differ in their _______
Code a statement that, depending on whether it occurs within a function or in the main code, determines whether
has global or local scope.
purchaseTotal = 3
Code something called
that does nothing but create
, which has local scope.
valueless = 0
Code a statement that assigns the value returned by a function to a global variable.
age = checkAge()
Code a function without parameters that does nothing but create two local variables.
firstVar = 2
secondVar = 9
Code a statement that passes the value of a local variable to a global variable in the main code.
Code a statement that passes the values of two global variables to a function and anticipates that the function will return a value to be assigned to a new global variable. The global variable hasn't been declared beforehand.
globalVar = processNums(num1, num2)
Code a function without parameters that creates two local variables and does nothing with them. Then it (unwisely) assigns the number 10 to a global variable that you've made up without a
safeVariable1 = 2
safeVariable2 = 3
Code the first line of a function that implicitly declares two local variables.
def doSomething(param1, param2):
The only place where a local variable has a value is within the ________ where it is declared.
YOU MIGHT ALSO LIKE...
Academic Word Lists - AWL Sublists
Chapter 6: Functions
Intro to C++ - Chapter 6
OTHER SETS BY THIS CREATOR
y9 topics: 1.4 networks y9, 1.6 System Security y9, 2.1 Algorithms - y9 revision v2, computer history v2
1.6 System Security y9
2.1 Algorithms - y9 revision v2
computer history v2