Functions and Scope
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Below is a single Python program, split up into several pieces for viewing. After each print
statement, provide the value that will be printed to the
screen.
If evaluating the print
statement in question would cause an error,
write error in the box.
x = 14
y = 28
a = 16
b = 9
def f(x):
return x + a
def f2(x):
return y + b
a = 17
print(f(1))
Relevant Reading about invoking custom functions.
print(f(a))
print(f2(a))
def f3(x, y):
a = x + y
return a + x + y
print(f3(49, 4))
print(a)
Next Exercise: Warehouse