Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

17. What is the output of this code? def func(a, b=5, c-10): printc\'a is\', a,

ID: 3600621 • Letter: 1

Question

17. What is the output of this code? def func(a, b=5, c-10): printc'a is', a, 'and b is', b, 'and c is'. e) func(c = 50, a 100) a.) a is 100 and b is 5 and c is 50 c. d. a is 100 and b is 50 and cis 100 syntax error 18. What is the output of this code? def maximum(x, y): if x > y: elifxy: else: return x return The numbers are equal return y print(maximum(2, 3)) c. The numbers are equal None of the mentioned 19. What is the output of this code? def power(x, y=2) for i in range(y): -.xl=1,3 r=r*x return r print (power(3, 3)) a. 9 C. d. None of the mentioned

Explanation / Answer

For question 17,

The answer will be OPTION A. This will be when we pass the parameters in the function func, in the definition we have already set the default values for the variables. So if we do not pass any values for those variables, then it will take those default values. The order for variables passed or arguments doesnot matter.

For question 18,

The answer will be OPTION B, value 3. When you call the function maximum(2,3), the first condition will fail as 2 is not greater than 3. Second function fails as 2 is not equal to 3 hence the last else will execute and will print 3.

For question 19,

The answer will be OPTION B, value 27. When you call the function power(3,3), it is actually calculating the power of a number, if you dont pass the value of y, then it will calculate the square of the value of x.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote