Questions: Return Values

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A function compute_tax(amount) prints the tax value inside the function. A developer writes total = amount + compute_tax(amount) expecting total to hold the sum. What will actually happen?

Atotal will hold the correct sum because the printed value is captured automatically
Btotal will be None (or cause a TypeError) because compute_tax returns nothing, not the tax value
Ctotal will hold just the amount, since print is ignored in arithmetic expressions
Dtotal will hold the printed string concatenated with amount
Question 2 Multiple Choice

Which of the following accurately describes what happens when Python executes a return statement inside a function?

AThe function displays the value and continues running any remaining statements
BThe function pauses execution and waits for the caller to request the value
CThe function immediately stops executing and sends the specified value back to the caller
DThe function stores the value in a global variable accessible to the caller
Question 3 True / False

A function can contain more than one return statement, and the first one that is reached during execution will end the function.

TTrue
FFalse
Question 4 True / False

Printing a result inside a function and returning a result from a function are equivalent, because both make the value available to the rest of the program.

TTrue
FFalse
Question 5 Short Answer

Why should a function that computes a result return it rather than print it?

Think about your answer, then reveal below.