Check your understanding of the chapter overview: what a function is, whether functions necessarily work correctly, and external functions.

Question 1

Which of the following is the best explanation of a function?

Select one answer, then check.

  • Correct. The overview describes a function as "a miniature program with its own input, processing, output workflow".
  • Not quite. This leaves out processing: a function also does something with its input on the way to its output.
  • Not quite. A function can involve much more than a single mathematical operation, such as printing, reading input, or working with strings.
  • Not quite. def is the keyword used to define a function; the function itself is the reusable chunk of code it creates.

Question 2

Which of the following is true?

Select one answer, then check.

  • Correct. Writing a function does not mean it works correctly; that's why the chapter covers testing.
  • Not quite. def defines a function; a unit test is written with assert_equal.
  • Not quite. The `bakery` library's testing function is named assert_equal, not check_equal.
  • Not quite. bakery only provides assert_equal; you still have to write the unit tests yourself.

Question 3

Which of the following is NOT true?

Select one answer, then check.

  • This is true, so it's not the answer: the whole point of external functions is that they live in a module you import.
  • This is true, so it's not the answer: a function has to exist, by definition or by import, before you can call it.
  • This is true, so it's not the answer: Drafter is a Python library whose functions you import, as the External Functions section of the reading shows.
  • Correct, this is NOT true. External functions are defined in one module and imported into another, which is exactly why the "External Functions" section exists.