Select the correct answerWhat will be the output of the following Python code?def demo(a, b=3, c=6): print('a is', a, 'and b is', b, 'and c is', c) demo(1, 5)demo(10, c = 15)demo(c = 30, a = 25)Optionsa is 5 and b is 1 and c is 10a is 10 and b is 3 and c is 15a is 3 and b is 25 and c is 30a is 1 and b is 5 and c is 6a is 10 and b is 3 and c is 15a is 25 and b is 3 and c is 30None of the mentioneda is 1 and b is 5 and c is 6a is 3 and b is 20 and c is 15a is 30 and b is 25 and c is 3
Question
Select the correct answerWhat will be the output of the following Python code?def demo(a, b=3, c=6): print('a is', a, 'and b is', b, 'and c is', c) demo(1, 5)demo(10, c = 15)demo(c = 30, a = 25)Optionsa is 5 and b is 1 and c is 10a is 10 and b is 3 and c is 15a is 3 and b is 25 and c is 30a is 1 and b is 5 and c is 6a is 10 and b is 3 and c is 15a is 25 and b is 3 and c is 30None of the mentioneda is 1 and b is 5 and c is 6a is 3 and b is 20 and c is 15a is 30 and b is 25 and c is 3
Solution
The correct answer is:
a is 1 and b is 5 and c is 6 a is 10 and b is 3 and c is 15 a is 25 and b is 3 and c is 30
Here's the step by step explanation:
-
In the first function call
demo(1, 5), 1 is assigned toaand 5 is assigned tob. Sincecis not specified, it takes the default value of 6. -
In the second function call
demo(10, c = 15), 10 is assigned toaand 15 is assigned toc. Sincebis not specified, it takes the default value of 3. -
In the third function call
demo(c = 30, a = 25), 25 is assigned toaand 30 is assigned toc. Sincebis not specified, it takes the default value of 3.
Similar Questions
Select the correct answerWhat will be the output of the following Python code?def demo(p,q): if(p == 0): return q else: return demo(p-1,p+q)print(demo(4,5))Options513Infinite loop15
Select the correct answerWhat will be the output of the following Python code?x = 'abcd'for i in range(len(x)): print(i)Optionsa b c d1 2 3 4error0 1 2 3
Select the correct answerWhat will be the output of the following Python code?def cb(a): return a * a * a a = cb(3) print(a)Options302739
What will be the output of the following Python code?def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c)func(3, 7)func(25, c = 24)func(c = 50, a = 100)a is 3 and b is 7 and c is 10a is 25 and b is 5 and c is 24a is 100 and b is 5 and c is 50a is 3 and b is 7 and c is 10a is 5 and b is 25 and c is 24a is 50 and b is 100 and c is 5None of the mentioneda is 7 and b is 3 and c is 10a is 25 and b is 5 and c is 24a is 5 and b is 100 and c is 50
What will be the output of the following code?a = "abce" >= "abcdef"print(a)Options: Pick one correct answer from belowTrueFalseBoth A and BNone of the Above
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.