Review: Scope

Module 1: Python Fundamentals

Review of Session 1.6: Python Scope

Exercise

Without running the code, what is going to be the output of this cell?

# What will be the output of this cell?
def add(a, b):
  result = a + b

  def multiply(a, b):
    return a * b

  print(multiply(a, b))

  return result

print(add(2, 3))
# What will be the output of this cell?
def add(a, b):
  result = a + b

  def multiply(c, d):
    return c * d

  print(multiply(a, b))

  return result

print(add(2, 3))
Exercise

Without running the code, what is going to be the output of this cell?

# What will be the output of this cell?
print = 7
print(print)

To fix the print() function, you will need to re-start this Python session.