[Type B] Working with Functions – Chapter 3 Sumita Arora

|
Table of Contents

10. Consider the code below and answer the questions that follow:

Python
def multiply(number1, number2):
    answer = number1 * number2
    print(number1, 'times', number2, '=', answer)
    return answer

output = multiply(5, 5)
  1. When the code above is executed, what prints out?
  2. What is variable output equal to after the code is executed?
  1. The code will print:
Output
5 times 5 = 25

This is because the multiply function calculates the product of number1 and number2 and then prints the result along with the values of number1 and number2.

  1. Variable output will be equal to the return value of the multiply function, which is 25. The function returns the product of the two numbers.

In short, output is:

  1. 5 times 5 = 25
  2. output is equal to 25.
"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *