Completed
Class 12 CS – Functions & Exception Handling
Questions From This Challenge
Q1mcq1 mark
What will be the output? def calculate(a, b=5): a = a + b b = a - b return a, b x, y = calculate(10) print(x, y)
15 5
15 10 ✓
10 5
20 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 ✓
27
32
Q3mcq1 mark
What will be the output? def change(x): x = x + 5 return x x = 10 y = change(x) print(x, y)
15 15
10 15 ✓
15 10
10 10
Q4mcq1 mark
What will be the output? x = 10 def change(): x = 20 x = x + 5 print(x) change() print(x)
25 25
25 10 ✓
20 10
10 25
Q5mcq1 mark
What will be the output? x = 5 def modify(): global x x = x + 10 print(x) modify() print(x)
5 15
15 5
15 15 ✓
5 5
Q6mcq1 mark
What will be the output? def first(x): x = x * 2 return second(x) def second(x): return x + 3 print(first(5))
10
13 ✓
15
8
Q7mcq1 mark
What will be the output? def calculate(a, b=4): a += b return a x = calculate(6) x = calculate(x, 2) print(x)
10
12 ✓
14
16
Q8mcq1 mark
What will be the output? def test(a, b=5): return a * b print(test(4, 3)) print(test(4))
12 20 ✓
20 12
12 12
20 20
Q9mcq1 mark
What will be the output? def calculate(a, b): try: result = a // b return result except ZeroDivisionError: return -1 finally: print("Checked") print(calculate(10, 0))
Checked
-1
Checked followed by -1 ✓
0 followed by Checked
Q10mcq1 mark
What will be the output? def test(): try: print("A") x = int("10") print("B") return x except ValueError: print("C") finally: print("D") print(test())
A B D 10 ✓
A B D
A B 10 D
A C D
Q11output1 mark
What will be the output?
try:
x = 10
y = 0
print(x // y)
except ZeroDivisionError:
print("Z")
finally:
print(x)
Correct output:
Z
10Q12output1 mark
What will be the output?
def calculate(a, b=2):
try:
return a // b
except ZeroDivisionError:
return -1
finally:
print("F")
x = calculate(10)
print(x)
Correct output:
F
5Q13output1 mark
What will be the output?
x = 10
def test():
x = 20
try:
print(x)
x = 30
return x
finally:
x = 40
print(x)
print(test())
print(x)
Correct output:
20
40
30
10Q14output1 mark
What will be the output?
def test(a, b=5):
try:
return a + b
except TypeError:
return 0
finally:
print("Done")
print(test(10, 2))
Correct output:
Done
12Q15output1 mark
What will be the output?
def calculate(a, b=5):
try:
return a // b
except ZeroDivisionError:
return -1
finally:
print("Checked")
print(calculate(20, 0))
Correct output:
Checked
-1