Completed
Class 12 CS – Functions, Global Variables & Types of Arguments
Questions From This Challenge
Q1mcq1 mark
What will be the output? def calculate(a, b=5): a = a + b return a x = calculate(10) y = calculate(x, 3) print(x, y)
15 18 ✓
15 20
10 18
15 15
Q2mcq1 mark
What will be the output? def test(a, b=10, c=5): return a + b - c print(test(20, c=8))
17
22 ✓
25
30
Q3output1 mark
What will be the output?
x = 10
def change():
x = 20
x = x + 5
print(x)
change()
print(x)
Correct output:
25
10Q4mcq1 mark
Which statement correctly describes the arguments in the function call? def display(a, b=10): print(a, b) display(20)
20 is a default argument and 10 is a positional argument
20 is a positional argument and 10 is a default value ✓
Both 20 and 10 are positional arguments
Both 20 and 10 are default arguments
Q5mcq1 mark
What will be the output? x = 5 def modify(): global x x = x + 10 print(x) modify() print(x)
5 5
15 5
15 15 ✓
10 15
Q6mcq1 mark
What will be the output? def calculate(a, b=4): x = a + b return x p = calculate(6) q = calculate(p, 2) print(p, q)
10 12 ✓
6 10
10 14
12 14
Q7output1 mark
What will be the output?
def test(a, b=5):
a = a * 2
b = b + 3
return a + b
print(test(4, 3))
print(test(4))
Correct output:
14
16Q8mcq1 mark
What will be the output? x = 10 def test(x): x = x + 5 print(x) test(20) print(x)
25 25
15 10
25 10 ✓
20 10
Q9mcq1 mark
What will be the output? def calculate(a, b=2): return a * b x = calculate(5) y = calculate(x, 3) print(x, y)
10 15
5 15
10 30 ✓
5 10
Q10mcq1 mark
What will be the output? x = 8 def change(): global x x = x * 2 return x a = change() x = x + 2 b = change() print(a, b, x)
16 36 36 ✓
16 36 18
16 36 38
16 34 34
Q11output1 mark
What will be the output?
def show(a, b=10, c=5):
return a + b + c
x = show(5)
y = show(5, 20)
z = show(5, 20, 30)
print(x, y, z)
Correct output:
20 30 55Q12mcq1 mark
What will be the output? x = 10 def first(): x = 20 return x def second(): global x x = x + 5 return x a = first() b = second() print(a, b, x)
20 15 15 ✓
20 15 10
20 15 20
10 15 15
Q13mcq1 mark
What will be the output? def calculate(a, b=5): return a - b x = calculate(20, 8) y = calculate(x) print(x, y)
12 7 ✓
12 17
15 10
20 15
Q14output1 mark
What will be the output?
x = 4
def update(a):
global x
x = x + a
return x
p = update(6)
q = update(p)
print(p, q, x)
Correct output:
10 20 20Q15output1 mark
What will be the output?
def process(a, b=4):
a = a + b
return a, b
x, y = process(6)
p, q = process(x, 3)
print(x, y)
print(p, q)
Correct output:
10 4
13 3