AmbifulWorksheets
Board exam practice paper
CBSE · Class 12 · Computer Science (083)

Computer Science: Board Exam Practice Paper

Time allowed: 3 hours · Maximum marks: 70 · AW-12CS-BP-71083

Name: Date: Score: ____ / 70
  1. This question paper contains 37 questions. All questions are compulsory. Some questions have an internal choice (marked OR): answer only one of them.
  2. The paper is divided into five sections: A, B, C, D and E.
  3. Section A has 21 questions of 1 mark each.
  4. Section B has 7 questions of 2 marks each.
  5. Section C has 3 questions of 3 marks each.
  6. Section D has 4 questions of 4 marks each.
  7. Section E has 2 questions of 5 marks each.
  8. All programming questions are to be answered using Python only.
  9. For a multiple-choice question, write the text of the correct answer as well.
Section A (21 × 1 = 21 marks)
1.
[1]What does this print?
s = 'learning python is fun'
print(len(s.split()))
  1. 5
  2. 3
  3. 22
  4. 4
2.
[1]What does this print?
s = 'files store data for later'
print('-'.join(s.split()))
  1. files-store-data-for-later
  2. files-store-data-for-later-
  3. files store data for later
  4. -files-store-data-for-later
3.
[1]What does this print?
d = {'mango': 45, 'papaya': 25, 'banana': 85}
d['papaya'] = d['papaya'] + 13
d['apple'] = 75
print(d)
  1. {'apple': 75, 'mango': 45, 'papaya': 38, 'banana': 85}
  2. {'mango': 45, 'papaya': 25, 'banana': 85, 'apple': 75}
  3. {'mango': 45, 'papaya': 38, 'banana': 85, 'apple': 75}
  4. {'mango': 45, 'papaya': 38, 'banana': 85}
4.
[1]Table: STUDENT
RollNo | Name | Sec | City | Marks
101 | Arjun | C | Delhi | 76
102 | Dev | B | Kochi | 87
103 | Ananya | C | Delhi | 79
104 | Priya | B | Kochi | 54
105 | Zoya | A | Kochi | 85
106 | Rahul | A | Delhi | 55
107 | Isha | C | Delhi | 63
108 | Meera | B | Pune | 76
Going by the data shown, which attribute can be the primary key?
  1. Sec
  2. RollNo
  3. City
  4. Marks
5.
[1]What does this print?
L = [14, 28, 41, 25, 32]
print(L * 4 == L + L + L + L, len(L * 4))
  1. False 5
  2. True 20
  3. False 20
  4. True 9
6.
[1]What does this print?
x = 9
def change():
    global x
    x = x + 8

change()
change()
change()
print(x)
  1. 17
  2. 41
  3. 33
  4. 9
7.
[1]What does this print?
s = 'DAtabase'
c = 0
for ch in s:
    if ch not in 'aeiouAEIOU':
        c = c + 1
print(c)
  1. 5
  2. 3
  3. 4
  4. 8
8.
[1]Which mode of communication is this: a radio station broadcasting to listeners?
  1. simplex
  2. broadcast only
  3. half-duplex
  4. full-duplex
9.
[1]Table: EMPLOYEE
EmpNo | Name | Dept | Salary | Bonus
E1 | Meera | Sales | 73000 | 9500
E2 | Kabir | HR | 76000 | NULL
E3 | Asha | IT | 63000 | 6000
E4 | Rahul | Sales | 72000 | 4500
E5 | Arjun | IT | 43000 | 2000
E6 | Ananya | HR | 26000 | 1000
E7 | Dev | IT | 65000 | NULL

SELECT Name, Salary FROM EMPLOYEE WHERE Name LIKE '%i%';
How many rows does this query return?
  1. 6
  2. 2
  3. 1
  4. 0
10.
[1]What does this print?
T = (14, 1, 2, 21, 10, 1)
print(T.count(1), T.index(1))
  1. 2 1
  2. 2 5
  3. 1 1
  4. 2 2
11.
[1]Which of these is a built-in function?
  1. math.sqrt()
  2. len()
  3. a function you define with def
  4. random.randint()
12.
[1]Which describes the bus topology?
  1. every node is attached to one backbone cable
  2. star networks joined in a hierarchy, branching from a root
  3. every node is connected to every other node
  4. each node is connected to two neighbours, forming a closed loop
13.
[1]Relation R has degree 5 and cardinality 3; relation S has degree 3 and cardinality 4. What is the degree of their Cartesian product R × S?
  1. 9
  2. 7
  3. 15
  4. 8
14.
[1]Opening a file for reading that does not exist raises:
  1. NameError
  2. EOFError
  3. ImportError
  4. FileNotFoundError (an IOError)
15.
[1]A row of a relation is called a:
  1. tuple
  2. domain
  3. attribute
  4. degree
16.
[1]What does this print?
def calc(a, b):
    return a + b, a * b

t = calc(10, 10)
print(t)
  1. 20 100
  2. 20
  3. [20, 100]
  4. (20, 100)
17.
[1]A signal uses frequencies from 70 MHz to 590 MHz. What is its bandwidth?
  1. 590 MHz
  2. 520 MHz
  3. 660 MHz
  4. 330 MHz
18.
[1]What does this print?
s = 'DATABASE'
print(s[3:5])
  1. AB
  2. ABA
  3. TAB
  4. A
19.
[1]Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Folder | Paper | 120 | 30
I02 | Ruler | Desk | 195 | 130
I03 | Eraser | Desk | 90 | 135
I04 | Pen | Writing | 230 | 105
I05 | Diary | Paper | 60 | 50
I06 | Crayons | Writing | 95 | 35

SELECT DISTINCT Category FROM ITEM ORDER BY Category;
How many rows does this query return?
  1. 6
  2. 4
  3. 3
  4. 2
20.
[1]Assertion (A): A file used with pickle.dump() must be opened in a text mode such as "w" or "a".
Reason (R): pickle.dump() writes a stream of bytes, not text.
  1. Both A and R are true, and R is the correct explanation of A.
  2. Both A and R are true, but R is not the correct explanation of A.
  3. A is true, but R is false.
  4. A is false, but R is true.
21.
[1]Assertion (A): The condition WHERE Player LIKE 'D%' in a query on PLAYER matches the value 'Shreya'.
Reason (R): In LIKE, % stands for any number of characters, so 'D%' matches every value that starts with D.
  1. Both A and R are true, and R is the correct explanation of A.
  2. Both A and R are true, but R is not the correct explanation of A.
  3. A is true, but R is false.
  4. A is false, but R is true.
Section B (7 × 2 = 14 marks)
22.
[2]Differentiate between a global variable and a local variable. Show both in an example: a global variable speed = 3, and a function display() with a local variable level = 49 that prints both; give the output.
OR
[2]Write the output of the following Python code:
f = open("school.txt", "w")
f.write("Grey\n")
f.write("Navy\n")
f.close()
f = open("school.txt", "w")
f.write("Red\n")
f.write("Pink\n")
f.close()
f = open("school.txt", "r")
data = f.readlines()
f.close()
print(len(data))
print(data[0].strip())
23.
[2]Predict the output of the following Python code:
code = "F6bKBe"
result = []
i = 0
while i < len(code):
    if code[i].isupper():
        result.append(code[i] * 2)
    elif code[i].isdigit():
        result.append(int(code[i]) + 3)
    else:
        result.append("#")
    i += 1
print(result)
24.
[2]Write the output of the following Python code:
def cost(units, price=40, less=10):
    return units * price - less
print(cost(4))
print(cost(4, 40))
OR
[2]Write a Python function count_start(words, ch) that takes a list of strings words and a letter ch, and prints how many words start with ch.
Example: if the input is ['market', 'student', 'eraser', 'window', 'ink'] and "m", the output should be 1.
25.
[2]Write the output of the following Python code:
text = "Maths Olympiad"
print(text[3:8])
print(text[-3::-3])
OR
[2]The Python program below should count the even numbers in the list data, but it has syntax and logical errors. Rewrite it after removing all the errors, and underline each correction.
data = [21, 47, 26, 38, 9, 55, 55]
count = 0
for i in range(len(data))
    if data[i] % 2 = 0:
        count =+ 1
print("Even numbers:" count)
26.
[2]Predict the output of the following Python code:
nums = [20, 135, 10, 185]
nums.insert(3, 209)
nums.remove(20)
print(nums)
print(nums.pop(2), len(nums))
27.
[2]Differentiate between DDL and DML in MySQL, with a suitable example of each on a table EVENT.
OR
[2]Write MySQL statements to: I. Add a column Qty of type INT to the table STUDENT. II. Delete the rows of STUDENT where Age is less than 50.
28.
[2]Name the protocol used to: (a) transfer files between two computers on a network; (b) download e-mail from a mail server to a computer.
OR
[2]What is the use of (a) a switch and (b) a router in a network?
Section C (3 × 3 = 9 marks)
29.
[3]Write and call a Python function CountVowels() to read the text file para.txt and count and display the number of vowels (a, e, i, o, u in capital or small letters) in it.
For example, suppose the file para.txt holds these lines (each ends with a newline):
Kites fly high in the sky
Our garden has roses
Birds sing every morning
Every child can learn
A cat sleeps on the wall
OR
[3]Write and call a Python function StartsWith() to read the text file story.txt and display the lines that start with the letter "T".
For example, suppose the file story.txt holds these lines (each ends with a newline):
A cat sleeps on the wall
Birds sing every morning
The river flows past our town
The bus was late today
Rain fell all night
30.
[3]A dictionary holds the marks of some students:
R = {'Zoya': 77, 'Ishaan': 79, 'Yash': 44, 'Aditi': 55}
Write the following user-defined functions to perform operations on a stack named Toppers:
I. Push_name(): push the names of the students who scored 60 or more into the stack.
II. Pop_name(): pop the names from the stack and display them. After all the names are popped, display "Stack Empty".
Expected Output:
Ishaan
Zoya
Stack Empty
31.
[3]Write a Python function avg_len(words) that adds up the lengths of all the words in a list and returns the average (mean) length. Call it for my_words = ['network', 'window', 'memory', 'screen'] and print the result.
OR
[3]Consider the tuple pairs = ((9, 7), (8, 6), (3, 3), (4, 4)). Write a Python function cnt_odd() to count the number of pairs (a, b) where both a and b are odd, and print the count.
Section D (4 × 4 = 16 marks)
32.
[4]Table: REGISTRATION
RegNo | StudentName | EventID
101 | Isha | E1
102 | Vikram | E2
103 | Kabir | E1
104 | Dev | E4
105 | Sana | E3
106 | Shreya | E1
Consider the table CHESS_EVENT given below and the table REGISTRATION above. Write the output of the following queries:
I. SELECT REGISTRATION.StudentName, CHESS_EVENT.EventName FROM REGISTRATION, CHESS_EVENT WHERE REGISTRATION.EventID = CHESS_EVENT.EventID AND CHESS_EVENT.Venue = 'Multi-Purpose Hall' ORDER BY REGISTRATION.StudentName;
II. SELECT COUNT(*) FROM CHESS_EVENT, REGISTRATION;
III. SELECT REGISTRATION.EventID, COUNT(*) FROM REGISTRATION GROUP BY REGISTRATION.EventID ORDER BY REGISTRATION.EventID;
IV. SELECT MAX(REGISTRATION.RegNo), MIN(REGISTRATION.RegNo) FROM REGISTRATION, CHESS_EVENT WHERE REGISTRATION.EventID = CHESS_EVENT.EventID AND CHESS_EVENT.EventName = 'Rapid Chess Cup';
Table: CHESS_EVENT
EventIDEventNameEventDateVenue
E1Blitz Open2025-04-13Multi-Purpose Hall
E2Junior Chess League2025-05-18Auditorium Hall
E3Rapid Chess Cup2025-06-11Multi-Purpose Hall
E4Puzzle Solving Round2025-10-10Activity Room 3
OR
[4]Consider the table CLUB_MEMBER given below. Write the output of the following queries:
I. SELECT Club, SUM(Points) FROM CLUB_MEMBER WHERE Club <> 'Chess Club' GROUP BY Club ORDER BY Club DESC;
II. SELECT DISTINCT Club FROM CLUB_MEMBER WHERE Points > 66 ORDER BY Club;
III. SELECT SUM(Points) FROM CLUB_MEMBER WHERE Club IN ('Art Club', 'Chess Club');
IV. SELECT MemberID, Points FROM CLUB_MEMBER WHERE Points BETWEEN 66 AND 79 ORDER BY Points DESC;
Table: CLUB_MEMBER
MemberIDMNameClubGradePoints
101VikramArt Club876
102AaravChess Club966
103NikhilScience Club879
104AshaChess Club1184
105YashScience Club1273
106AdityaArt Club1127
33.
[4]Nisha is a class teacher and keeps the marks of the class in a CSV file named Students.csv, each row holding Roll_No, Name, Marks. Write the following user-defined functions:
I. AddStudent() – to accept a record from the user and append it to Students.csv.
II. ShowToppers() – to display the names of the students who scored 90 or more, and then how many they are.
For example, if the file holds these rows:
1,Kiran,95
2,Neel,94
3,Tara,95
4,Farhan,63
then ShowToppers() displays:
Kiran
Neel
Tara
Count: 3
34.
[4]Table: PLAYER_ENTRY
EntryNo | Player | MatchID
101 | Arjun | M2
102 | Tanvi | M3
103 | Ishaan | M4
104 | Sana | M5
105 | Priya | M2
106 | Harsh | M5
107 | Pooja | M2
Consider the table MATCH_FIXTURE given below and the table PLAYER_ENTRY above (MatchID in PLAYER_ENTRY refers to MatchID in MATCH_FIXTURE). Write MySQL queries for the following:
I. Write a query to change the Ground of the match "Friendly Match" to "Sports Complex".
II. Display the details of all matches held before 2025-06-23.
III. Display the Player and MatchID of the players registered for matches held in ‘Main Ground’ or ‘Indoor Hall’.
IV. Display the Player along with the Fixture for all registrations.
Table: MATCH_FIXTURE
MatchIDFixtureMatchDateGround
M1House Cup2025-05-08Indoor Hall
M2Under-17 Semi-final2025-05-10Main Ground
M3Friendly Match2025-05-27Main Ground
M4Zonal Qualifier2025-06-23Main Ground
M5Under-14 Final2026-01-20Indoor Hall
35.
[4]The MySQL database StoreDB has a table product with the attributes PCode (integer), PName (string), Category (string) and Price (integer). Consider the following details to establish Python–MySQL connectivity: Host: localhost; Username: manager; Password: lib@2025; Database: StoreDB. Write a Python–MySQL program to display the PName and Price of the records whose Price is more than 193.
Section E (2 × 5 = 10 marks)
36.
[5]A school office manager, Farhan, keeps records in the binary file Staff.dat. Each record is a list [Emp_No, Name, Department, Salary]. Write Python functions to:
I. AddStaff() – input the details of a record and append it to the binary file. (2)
II. ShowSalaryAbove(limit) – display every record whose Salary is more than limit, and then the number of such records. (3)
37.
[5]Tech-Innovate Pvt Ltd is setting up a network on its campus at Kochi, which has four blocks: Block C, Block D, Block A, Block B. The distances between the blocks are given in the table below. The number of computers in each block: Block C 120, Block D 70, Block A 45, Block B 50.
I. Suggest the most suitable block to install the server, with a reason.
II. Suggest the most suitable topology for connecting all the blocks, if the organisation wants centralised network management.
III. Suggest the placement of (a) a repeater and (b) a switch, with reasons.
IV. The organisation plans to link its office in Chennai. Suggest a way to connect it with a reasonably high-speed guided medium.
V. What type of network (PAN, LAN, MAN or WAN) will be formed between the campus and the office in that other city?
Distances between the blocks
FromToDistance
Block CBlock D155 m
Block CBlock A95 m
Block CBlock B150 m
Block DBlock A90 m
Block DBlock B115 m
Block ABlock B120 m
AmbifulWorksheets
Marking scheme
CBSE · Class 12 · Computer Science (083)

Marking scheme

Computer Science: Board Exam Practice Paper · AW-12CS-BP-71083 · For the parent or teacher: award the marks shown for each step, even when the final answer is wrong.

QAnswer and marks for each stepMarks
Section A (21 × 1 = 21 marks)
1(d) 4
split() with no argument splits at spaces
1
2(a) files-store-data-for-later
join() puts the separator between the words
1
3(c) {'mango': 45, 'papaya': 38, 'banana': 85, 'apple': 75}
assigning to an existing key changes it; a new key is added at the end
1
4(b) RollNo
RollNo is the only attribute here whose values are all different and never NULL (two students share marks)
1
5(b) True 20
L * 4 repeats the list 4 times, so it has 20 items
1
6(c) 33
global x makes the function change the variable outside it
1
7(c) 4
check each character in turn
1
8(a) simplex1
9(c) 1
rows where Name LIKE '%i%'
1
10(a) 2 1
1 occurs twice; its first index is 1
1
11(b) len()1
12(a) every node is attached to one backbone cable1
13(d) 8
5 + 3: every attribute of both
1
14(d) FileNotFoundError (an IOError)1
15(a) tuple1
16(d) (20, 100)
return a + b, a * b returns a tuple of two values
1
17(b) 520 MHz
590 − 70: bandwidth is the range of frequencies
1
18(a) AB
count indices from 0; the stop index is not included
1
19(c) 3
DISTINCT keeps one of each value: Desk, Paper, Writing
1
20(d) A is false, but R is true.
A is false: pickle writes bytes, so it needs a binary mode, not a text mode. R is true.
1
21(d) A is false, but R is true.
A is false: 'Shreya' does not start with D. R is true.
1
Section B (7 × 2 = 14 marks)
22Global variable: defined outside every function; it can be used anywhere in the program. Local variable: defined inside a function; it can be used only inside that function.
Example:
speed = 3 # global
def display():
    level = 49 # local
    print(speed, level)
display()
print(speed)
Output:
3 49
3
Here speed is global: it is used both inside and outside display(). level is local to display(): using it outside display() gives a NameError.
  1. Correct difference (global: outside, usable anywhere; local: inside a function, usable only there) (1)
  2. Example of a global variable (speed) (0.5)
  3. Example of a local variable (level) (0.5)
2
22 OR2
Red
  1. 2 (the second "w" erases the earlier lines) (1)
  2. Red (1)
2
23['FF', 9, '#', 'KK', 'BB', '#']
  1. Correct output list (2)
2
24150
150
  1. 150 (default values used) (1)
  2. 150 (1)
2
24 ORdef count_start(words, ch):
    count = 0
    for w in words:
        if w.startswith(ch):
            count += 1
    print(count)
  1. Correct function header (0.5)
  2. Correct logic (or similar) (1)
  3. Correct print statement (0.5)
2
25
  1. hs Ol (1)
  2. iy t (1)
2
25 OR
  1. colon at the end of the for statement (0.5)
  2. == (comparison) in place of = in the if condition (0.5)
  3. count += 1 in place of count =+ 1, which sets count to 1 (logical error) (0.5)
  4. comma between the two values printed (0.5)
2
26[135, 10, 209, 185]
209 3
  1. [135, 10, 209, 185] (1)
  2. 209 3 (pop() runs before len(), so the length is after the pop) (1)
2
27DDL (Data Definition Language) commands define or change the structure of tables, e.g. CREATE, ALTER, DROP. DML (Data Manipulation Language) commands work on the data in tables, e.g. INSERT, UPDATE, DELETE. Example: ALTER TABLE EVENT ADD Age INT; / DELETE FROM EVENT;
  1. DDL (Data Definition Language) commands define or change the structure of tables, e.g. CREATE, ALTER, DROP; DML (Data Manipulation Language) commands work on the data in tables, e.g. INSERT, UPDATE, DELETE (1)
  2. example of DDL: ALTER TABLE EVENT ADD Age INT; (0.5)
  3. example of DML: DELETE FROM EVENT; (0.5)
2
27 OR
  1. I. ALTER TABLE STUDENT ADD Qty INT; (1)
  2. II. DELETE FROM STUDENT WHERE Age < 50; (1)
2
28
  1. (a) FTP (File Transfer Protocol) (1)
  2. (b) POP3 (Post Office Protocol 3) (1)
2
28 OR(a) A switch connects computers in a network and sends each packet only to the computer it is meant for. (b) A router connects different networks and finds the best path for data from one network to another.
  1. a switch connects computers in a network and sends each packet only to the computer it is meant for (1)
  2. a router connects different networks and finds the best path for data from one network to another (1)
2
Section C (3 × 3 = 9 marks)
29def CountVowels():
    f = open("para.txt", "r")
    count = 0
    data = f.read()
    for ch in data:
        if ch in "aeiouAEIOU":
            count += 1
    print("Vowels:", count)
    f.close()
CountVowels()
For the file above it displays:
Vowels: 31
  1. Correct function header (0.5)
  2. Correctly opening the file (0.5)
  3. Correct logic (or similar) for the required output (1.5)
  4. Correctly calling the function (0.5)
3
29 ORdef StartsWith():
    f = open("story.txt", "r")
    for line in f:
        if line[0] == "T":
            print(line, end="")
    f.close()
StartsWith()
For the file above it displays:
The river flows past our town
The bus was late today
  1. Correct function header (0.5)
  2. Correctly opening the file (0.5)
  3. Correct logic (or similar) for the required output (1.5)
  4. Correctly calling the function (0.5)
3
30R = {'Zoya': 77, 'Ishaan': 79, 'Yash': 44, 'Aditi': 55}
Toppers = []
def Push_name():
    for name in R:
        if R[name] >= 60:
            Toppers.append(name)
def Pop_name():
    while len(Toppers) > 0:
        print(Toppers.pop())
    print("Stack Empty")
  1. I. Correct push function (1.5)
  2. II. Correct pop function, ending with "Stack Empty" (1.5)
3
31def avg_len(words):
    total = 0
    count = 0
    for w in words:
        total += len(w)
        count += 1
    return total / count
my_words = ['network', 'window', 'memory', 'screen']
print("Average word length:", avg_len(my_words))
It prints: Average word length: 6.25
  1. Correct function definition (0.5)
  2. Correct logic (or similar) (2)
  3. Correct return and print statement (0.5)
3
31 ORpairs = ((9, 7), (8, 6), (3, 3), (4, 4))
def cnt_odd(t):
    c = 0
    for a, b in t:
        if a % 2 == 1 and b % 2 == 1:
            c += 1
    return c
print("Number of odd-odd pairs:", cnt_odd(pairs))
It prints: Number of odd-odd pairs: 2
  1. Correct function definition (0.5)
  2. Correct logic (or similar) (2)
  3. Correct return and print statement (0.5)
3
Section D (4 × 4 = 16 marks)
32
  1. I. StudentName | EventName / Isha | Blitz Open / Kabir | Blitz Open / Sana | Rapid Chess Cup / Shreya | Blitz Open (1)
  2. II. COUNT(*) / 24 (1)
  3. III. EventID | COUNT(*) / E1 | 3 / E2 | 1 / E3 | 1 / E4 | 1 (1)
  4. IV. MAX(REGISTRATION.RegNo) | MIN(REGISTRATION.RegNo) / 105 | 105 (1)
4
32 OR
  1. I. Club | SUM(Points) / Science Club | 152 / Art Club | 103 (1)
  2. II. Club / Art Club / Chess Club / Science Club (1)
  3. III. SUM(Points) / 253 (1)
  4. IV. MemberID | Points / 103 | 79 / 101 | 76 / 105 | 73 / 102 | 66 (1)
4
33import csv
def AddStudent():
    Roll_No = input("Enter Roll No: ")
    Name = input("Enter Name: ")
    Marks = input("Enter Marks: ")
    with open("Students.csv", "a", newline="") as f:
        w = csv.writer(f)
        w.writerow([Roll_No, Name, Marks])
    print("Record added.")

def ShowToppers():
    count = 0
    with open("Students.csv", "r") as f:
        for row in csv.reader(f):
            if int(row[2]) >= 90:
                print(row[1])
                count += 1
    print("Count:", count)
  1. I. Correctly taking the input (0.5)
  2. I. Opening the file in append mode (0.5)
  3. I. Correctly creating the writer object (0.5)
  4. I. Correctly using writerow() (0.5)
  5. II. Opening the file in the right mode (0.5)
  6. II. Correctly reading the rows with csv.reader() (0.5)
  7. II. Correct condition, converting to int (0.5)
  8. II. Correctly displaying the names and the count (0.5)
4
34
  1. I. UPDATE MATCH_FIXTURE SET Ground = 'Sports Complex' WHERE Fixture = 'Friendly Match'; (1)
  2. II. SELECT * FROM MATCH_FIXTURE WHERE MatchDate < '2025-06-23'; (1)
  3. III. SELECT PLAYER_ENTRY.Player, PLAYER_ENTRY.MatchID FROM PLAYER_ENTRY, MATCH_FIXTURE WHERE PLAYER_ENTRY.MatchID = MATCH_FIXTURE.MatchID AND MATCH_FIXTURE.Ground IN ('Main Ground', 'Indoor Hall'); (1)
  4. IV. SELECT PLAYER_ENTRY.Player, MATCH_FIXTURE.Fixture FROM PLAYER_ENTRY, MATCH_FIXTURE WHERE PLAYER_ENTRY.MatchID = MATCH_FIXTURE.MatchID; (1)
4
35import mysql.connector
con = mysql.connector.connect(host="localhost", user="manager", password="lib@2025", database="StoreDB")
cur = con.cursor()
cur.execute("SELECT PName, Price FROM product WHERE Price > 193")
rows = cur.fetchall()
for row in rows:
    print(row)
con.close()
  1. importing mysql.connector (0.5)
  2. creating the connection object with connect() (0.5)
  3. creating the cursor object (0.5)
  4. the correct query: SELECT PName, Price FROM product WHERE Price > 193; (1)
  5. executing it and reading the rows with fetchall(), printed in a loop (1)
  6. closing the connection (0.5)
4
Section E (2 × 5 = 10 marks)
36import pickle
def AddStaff():
    Emp_No = int(input("Enter Emp No: "))
    Name = input("Enter Name: ")
    Department = input("Enter Department: ")
    Salary = int(input("Enter Salary: "))
    rec = [Emp_No, Name, Department, Salary]
    with open("Staff.dat", "ab") as f:
        pickle.dump(rec, f)
    print("Record added.")

def ShowSalaryAbove(limit):
    count = 0
    with open("Staff.dat", "rb") as f:
        try:
            while True:
                rec = pickle.load(f)
                if rec[3] > limit:
                    print(rec)
                    count += 1
        except EOFError:
            pass
    print("Records found:", count)
For example, if the file holds [501, 'Tara', 'Accounts', 31000], [502, 'Ishaan', 'Accounts', 41000], [503, 'Farhan', 'Library', 45000], [504, 'Sana', 'Admin', 30000], ShowSalaryAbove(31000) displays:
[502, 'Ishaan', 'Accounts', 41000]
[503, 'Farhan', 'Library', 45000]
Records found: 2
  1. I. Correct function header (0.5)
  2. I. Opening the file in append binary mode (0.5)
  3. I. Correctly taking the input (0.5)
  4. I. Using pickle.dump() (0.5)
  5. II. Correct function header (0.5)
  6. II. Correctly opening the file in "rb" mode (0.5)
  7. II. Using load() in a while loop with try-except (1)
  8. II. Checking the condition, displaying and counting (1)
5
37
  1. I. Block C, as it has the most computers (120). (1)
  2. II. Star topology, with Block C (the server) at the centre, connected to each other block. (1)
  3. III. (a) Repeaters on the cables from Block C to Block D and Block B, as these distances are more than 100 m. (b) A switch in every block, to connect the computers of that block. (1)
  4. IV. Optical fibre cable. (1)
  5. V. WAN (Wide Area Network), as the two places are in different cities. (1)
5