INSY 3300 Test 2 Review 2025
Questions and Answers
Python function names follow the same rules as those for naming variables. - --
Answer --True
A local variable can be accessed from anywhere in the program. - --Answer -
-False
What will the output be after running the following code snippet?
def myfunc(num)
if num >= 4:
return num - 1
else:
return 2
print ( my func(4))
1
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 1
,2
3
4 - --Answer --3
One reason not to use global variables is that it makes a program hard to debug. - -
-Answer --True
What does the following statement mean?
num1, num2 = get_num()
-The function get_num ( ) is expected to return one value and assiagn it to num1
an num2
-This statement will cause a syntax error
-The function get_num ( ) is expected to return a value for num1 and for num 2
-The function get_num ( ) will recieve the values stored in num 1 and num 2 - --
Answer --The function get_num( ) is expected tor return a value for num1
and for num2
What will be the output after the following is executed?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 2
,def pass_it(x, y):
z = x + ", " + y
return(z)
def main():
name2 = "Julian"
name1 = "Smith"
fullname = pass_it(name1, name2)
print(fullname)
main()
-Julian, Smith
-Julian Smith
-Smith Julian
-Smith, Julian - --Answer --Smith, Julian
What will the output be after running the following code?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 3
, def swap(x, y):
z = x;
x = y;
y = z;
def main():
x=5
y = 10
swap(x, y)
print(x, y, end=' ')
- 10 5
- prints nothing
- error
- 5 10 - --Answer --5 10
What will be the output after the following code is executed?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 4
Questions and Answers
Python function names follow the same rules as those for naming variables. - --
Answer --True
A local variable can be accessed from anywhere in the program. - --Answer -
-False
What will the output be after running the following code snippet?
def myfunc(num)
if num >= 4:
return num - 1
else:
return 2
print ( my func(4))
1
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 1
,2
3
4 - --Answer --3
One reason not to use global variables is that it makes a program hard to debug. - -
-Answer --True
What does the following statement mean?
num1, num2 = get_num()
-The function get_num ( ) is expected to return one value and assiagn it to num1
an num2
-This statement will cause a syntax error
-The function get_num ( ) is expected to return a value for num1 and for num 2
-The function get_num ( ) will recieve the values stored in num 1 and num 2 - --
Answer --The function get_num( ) is expected tor return a value for num1
and for num2
What will be the output after the following is executed?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 2
,def pass_it(x, y):
z = x + ", " + y
return(z)
def main():
name2 = "Julian"
name1 = "Smith"
fullname = pass_it(name1, name2)
print(fullname)
main()
-Julian, Smith
-Julian Smith
-Smith Julian
-Smith, Julian - --Answer --Smith, Julian
What will the output be after running the following code?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 3
, def swap(x, y):
z = x;
x = y;
y = z;
def main():
x=5
y = 10
swap(x, y)
print(x, y, end=' ')
- 10 5
- prints nothing
- error
- 5 10 - --Answer --5 10
What will be the output after the following code is executed?
....COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 4