Completed

Class 12 CS – Complete Python Test

Class 12 · Computer Science Sat, 26 Sep 2026 11:00 PM 60s / question 15 questions · 15 marks

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(12) print(x, y)
17 5
17 12 ✓
12 17
5 17
Q2mcq1 mark
What will be the output? def process(x): x = x + 5 return x x = 10 y = process(x) x = x + 2 print(x, y)
10 15
12 15 ✓
15 12
12 17
Q3mcq1 mark
What will be the output? x = 10 def change(): x = 20 x = x + 5 return x y = change() print(y, x)
25 25
20 10
25 10 ✓
10 25
Q4mcq1 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
32
Q5mcq1 mark
What will be printed? try: x = int("15") y = 0 print(x // y) except ValueError: print("V") except ZeroDivisionError: print("Z") finally: print("F")
V F
Z F ✓
F
Z
Q6mcq1 mark
A text file contains: COMPUTER The following code is executed: f = open("data.txt", "r+") x = f.read(3) f.write("XYZ") f.close() What is the content of the file after execution?
COMXYZER ✓
XYZPUTER
COMXYZPUTER
COMPUTERXYZ
Q7mcq1 mark
What will be the output? f = open("data.txt", "w+") f.write("PYTHON") f.seek(2) x = f.read(2) print(x) f.close()
PY
YT
TH ✓
HO
Q8mcq1 mark
What will be the output? f = open("data.txt", "r") x = f.read(5) y = f.readline() print(y.strip()) f.close()
ABC
DE
EF ✓
GHI
Q9mcq1 mark
What will be the output? import pickle f = open("data.dat", "wb") pickle.dump(10, f) pickle.dump(20, f) f.close() f = open("data.dat", "rb") a = pickle.load(f) b = pickle.load(f) print(b - a) f.close()
10 ✓
20
30
0
Q10mcq1 mark
What will be the output? import pickle f = open("data.dat", "wb") pickle.dump(5, f) pickle.dump(10, f) pickle.dump(15, f) f.close() f = open("data.dat", "rb") pickle.load(f) x = pickle.load(f) print(x) f.close()
5
10 ✓
15
25
Q11mcq1 mark
Consider the following CSV data: Name,Marks Amit,80 Riya,75 What will be printed by the following code? import csv f = open("data.csv", "r") r = csv.reader(f) next(r) row = next(r) print(row[1]) f.close()
Name
Marks
80 ✓
Amit
Q12mcq1 mark
What will be the output? import csv f = open("data.csv", "w", newline="") w = csv.writer(f) w.writerow(["A", 10]) w.writerow(["B", 20]) f.close() f = open("data.csv", "r") r = csv.reader(f) total = 0 for row in r: total = total + int(row[1]) print(total) f.close()
20
30 ✓
40
1020
Q13mcq1 mark
What will be the final stack? stack = [10, 20] stack.append(30) x = stack.pop() stack.append(x + 5) stack.pop() print(stack)
[10, 20] ✓
[10, 25]
[10, 20, 35]
[10, 30]
Q14mcq1 mark
What will be printed? stack = [5, 10, 15, 20] a = stack.pop() b = stack.pop() stack.append(a + b) print(stack[-1])
15
20
30
35 ✓
Q15mcq1 mark
What will be the output? def transfer(s1, s2): x = s1.pop() s2.append(x + 5) s1 = [10, 20, 30] s2 = [40] transfer(s1, s2) transfer(s1, s2) print(s1[-1], s2[-1])
10 35
10 25 ✓
20 35
20 25
Next Live Challenge
Mixed: DML + Retrieval - Combined Application
Class 12 · Computer Science Fri, 23 Oct 2026, 9:00 PM
View Live Challenges →

← Back to Live Challenge History · Practice MCQs

CodeBuddy
Hi there! 👋 I'm CodeBuddy, your KV Coders assistant.

To help me give you the most accurate answers, please select your class and subject below, or just type your question!
Buddy is typing...