Questions: Defining and Calling Functions

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A programmer writes the following Python code: def say_hello(): print('Hello!') say_hello What happens when this code runs?

AIt prints 'Hello!' once
BIt prints 'Hello!' and then returns to the definition
CNothing is printed — the function is referenced but not called
DPython raises a NameError because say_hello is not yet defined
Question 2 Multiple Choice

What is the primary benefit of wrapping repeated code into a named function?

AIt makes the code run faster by pre-compiling the function body at definition time
BIt allows the code to execute once during definition and then be reused cheaply
CIt hides implementation details behind a meaningful name and allows the code to be called multiple times without rewriting it
DIt ensures the function body runs automatically whenever a related variable changes
Question 3 True / False

Defining a function in Python causes its code to execute immediately.

TTrue
FFalse
Question 4 True / False

A single function definition can be used to produce results at multiple different points in a program.

TTrue
FFalse
Question 5 Short Answer

Explain the difference between defining a function and calling a function, and describe what actually happens during each step.

Think about your answer, then reveal below.