Question | Click to View Answer |
What does the following code print? x = 55
def hi():
return x
print(hi())
|
The variable |
What does the following code print? def pointless():
z = 77
return z
print(pointless())
|
The variable |
What does the following code print? def chair():
pp = 99
return pp
chair()
print(pp)
|
This code raises a The |
What does the following code print? ii = 50
def fan():
ii = 100
return ii
print(fan())
|
The The local scope is used when there is a collision with a variable of the same name in the global scope. |
What does the following code print? qq = 3
def bike():
qq = 7
bike()
print(qq)
|
When a global variable is reassigned in the local scope of a function, the reassignment only holds within the local scope. The variable goes back to the global value when the code returns the global scope. |
What does the following code print? nn = 9
if True:
nn = 16
print(nn)
|
|
What does the following code print? cc = 2
if False:
cc = 66
def helmet():
if True:
cc = 40
helmet()
print(cc)
|
|