What will be the output of following code?def sum_multiply(a,b,*more): sum_value = a+b m_value = a*b for i in more: sum_value += i m_value*=i return sum_value,m_values_m = sum_multiply(2,3,4)print(s_m)infoYou have max 2 attempts to score in this question.Attempts left:1/2OptionsThis problem has only one correct answer9,24(9,24)Error(5,6)warningWrong Answer, Attempt Again
Question
What will be the output of following code?def sum_multiply(a,b,more): sum_value = a+b m_value = ab for i in more: sum_value += i m_value*=i return sum_value,m_values_m = sum_multiply(2,3,4)print(s_m)infoYou have max 2 attempts to score in this question.Attempts left:1/2OptionsThis problem has only one correct answer9,24(9,24)Error(5,6)warningWrong Answer, Attempt Again
Solution
The output of the code will be an error. This is because in the return statement, the variable is named "m_value" but in the print statement, the variable is named "s_m". The variable names should be consistent. If you change "s_m" to "m_value" in the print statement, the output will be (9,24).
Similar Questions
def sum_multiply(a,b,*more): sum_value = a+b m_value = a*b for i in more: sum_value += i m_value*=i return sum_value,m_values_m = sum_multiply(2,3,4)print(s_m)
What will be the output of the following Python code?m = 3 def ct1(): global m m = 1def ct2(p,q): global m return p+q+mct1()sum = ct2(2,4)print(sum)OptionsError7910
Problem SolvingWhat will be the output of the following program?def sum(*args): '''Function returns the sum of all values''' result = 0 for i in args: result += i return resultprint(sum.__doc__)print(sum(4, 5, 6, 5))print(sum(5, 6, 20, 4, 5))Select all the correct statements given below.OptionsFunction returns the sum of all values203020302040Function returns the sum of all values2040
answerWhat are the values of the following Python expressions?2**(3**2) (2**3)**2 2**3**2Options512, 64, 51264, 512, 64512, 512, 512
What will be the output of the following Python code?1. def find_max(a, b):2. if a > b:3. print(a, 'is maximum')4. elif a == b:5. print(a, 'is equal to', b)6. else:7. print(b, 'is maximum')8. 9. find_max(3, 4)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.