Question
Part 4 Textbook Exercises - Functions def findTheMaxValue( num1 , num2 ): maxVal = 0 if ( num1 > num2 ) : # if num1
Part 4 Textbook Exercises - Functions
def findTheMaxValue(num1, num2):
maxVal = 0
if (num1 > num2) : # if num1 is greater than num2,
maxVal = num1 # then num1 is the maximum value.
else : # Otherwise,
maxVal = num2 # num2 is the maximum value.
return maxVal
numA = 4 ; numB = 11
numC = 13 ; numD = 7
maxSum = 0
maxSum = maxSum + findTheMaxValue(numA, numC)
maxSum = maxSum + findTheMaxValue(numD, numB)
# the result
print("the maximum_sum is :", maxSum)
For the these exercises, refer to the above function definition and the above function call.
(1) ( Functions )
Predict the result when the above code statements are executed.
(a) 24 (b) 11 (c) 143 (d) 28 (e) 13
(2) ( Functions )
How many parameters does the function named findTheMaxValue have?
(a) 0 (b) 1 (c) 2 (d) 3 (e) 4
(3) ( Functions )
Which of these variables is a parameter of the findTheMaxValue function?
(a) num1 (b) maxVal (c) maxSum (d) numB (e) numA
(4) ( Functions )
Which of these variables is local to the findTheMaxValue function?
(a) numC (b) maxVal (c) maxSum (d) numB (e) numA
(5) ( Functions )
Which of these variables is defined outside the findTheMaxValue function definition?
(a) numC (b) numB (c) numA (d) numD (e) all of these
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started