Computer Science · 083SQP-2026·All India (AI)

CBSE Official Class 12 Computer Science Sample Question Paper with step-by-step Chief Examiner marking scheme solutions (All 37 Questions Solved, 70 Marks).

Jump to:
1
Section A(1-Mark Questions)
1 Mark
State True or False:
The Python interpreter handles logical errors during code execution.
CBSE Official Step-Marking AllocationTotal: 1 M
State False with justification that logical errors are semantic flaws undetectable by the interpreter
+1 M
NCERT / CBSE Model Answer
Answer: False
Justification:
The Python interpreter detects and handles syntax errors (parsing phase) and runtime exceptions (execution phase). A logical error (or semantic bug) occurs when the code runs without crashing but produces unintended or incorrect results. The interpreter cannot detect logical errors because the program syntax and operations are valid.
Chief Examiner Evaluation Report & Pitfalls:

Syntax errors and runtime exceptions are caught by the interpreter; logical errors must be debugged by the programmer through testing.

2
Section A(1-Mark Questions)
1 Mark
Identify the output of the following code snippet:
``python
text = "PYTHONPROGRAM"
text = text.replace('PY', '#')
print(text)
`
(A)
#THONPROGRAM
(B)
##THON#ROGRAM
(C)
#THON#ROGRAM
(D)
#YTHON#ROGRAM`
CBSE Official Step-Marking AllocationTotal: 1 M
Identify single occurrence of 'PY' replaced by '#', selecting Option (A)
+1 M
NCERT / CBSE Model Answer
Correct Option: (A) #THONPROGRAM
Justification:
1. In the string "PYTHONPROGRAM", the substring 'PY' occurs only once at the beginning (indices 0 and 1).
2. text.replace('PY', '#') replaces the exact sequence 'PY' with '#'.
3. The remaining substring 'THONPROGRAM' does not contain 'PY'.
4. Therefore, text becomes '#THONPROGRAM', matching Option (A).
Chief Examiner Evaluation Report & Pitfalls:

String method `.replace(old, new)` matches the contiguous substring 'old'. It does not replace individual characters 'P' and 'Y' separately.

3
Section A(1-Mark Questions)
1 Mark
Which of the following expressions evaluates to False?
(A) not(True) and False
(B) True or False
(C) not(False and True)
(D) True and not(False)
CBSE Official Step-Marking AllocationTotal: 1 M
Evaluate Boolean logic: not(True) and False = False and False = False, Option (A)
+1 M
NCERT / CBSE Model Answer
Correct Option: (A) not(True) and False
Justification:
- (A) not(True) is False. False and False evaluates to False.
- (B) True or False evaluates to True.
- (C) False and True is False. not(False) evaluates to True.
- (D) not(False) is True. True and True evaluates to True.
Therefore, Option (A) evaluates to False.
Chief Examiner Evaluation Report & Pitfalls:

Operator precedence: `not` has higher precedence than `and`, which has higher precedence than `or`.

4
Section A(1-Mark Questions)
1 Mark
What is the output of the expression?
``python
country = 'International'
print(country.split("n"))
`
(A)
('I', 'ter', 'atio', 'al')
(B)
['I', 'ter', 'atio', 'al']
(C)
['I', 'n', 'ter', 'n', 'atio', 'n', 'al']`
(D) Error
CBSE Official Step-Marking AllocationTotal: 1 M
Identify that .split() produces a list without the delimiter, choosing Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) ['I', 'ter', 'atio', 'al']
Justification:
1. The .split(sep) method always returns a list of substrings separated by the delimiter sep.
2. Splitting 'International' at 'n':
- Before 1st 'n': 'I'
- Between 1st and 2nd 'n': 'ter'
- Between 2nd and 3rd 'n': 'atio'
- After 3rd 'n': 'al'
3. The separator 'n' is removed from the resulting elements.
4. Output: ['I', 'ter', 'atio', 'al'] (Option B).
Chief Examiner Evaluation Report & Pitfalls:

Remember `.split()` produces a `list` (square brackets `[]`), never a `tuple` (parentheses `()`).

5
Section A(1-Mark Questions)
1 Mark
What will be the output of the following code snippet?
``python
message = "World Peace"
print(message[-2::-2])
``
CBSE Official Step-Marking AllocationTotal: 1 M
Trace negative slice [-2::-2] to obtain ce lo
+1 M
NCERT / CBSE Model Answer
Answer: ce lo
Justification:
1. String: message = "World Peace" (length 11, indices 0 to 10).
- Positive indices: W(0), o(1), r(2), l(3), d(4), ' '(5), P(6), e(7), a(8), c(9), e(10)
- Negative indices: e(-1), c(-2), a(-3), e(-4), P(-5), ' '(-6), d(-7), l(-8), r(-9), o(-10), W(-11)
2. Slice expression message[-2::-2]:
- start = -2 (character 'c')
- stop = None (runs to the start of the string in reverse)
- step = -2 (every second character backwards)
3. Sequence of indices accessed:
- -2: 'c'
- -4: 'e'
- -6: ' ' (space)
- -8: 'l'
- -10: 'o'
4. Combining these gives: "ce lo".
Chief Examiner Evaluation Report & Pitfalls:

Pay close attention to spaces in slicing. Index -6 corresponds to the space character between World and Peace.

6
Section A(1-Mark Questions)
1 Mark
What will be the output of the following code?
``python
tuple1 = (1, 2, 3)
tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2)
``
(A) True
(B) False
(C) tuple1
(D) Error
CBSE Official Step-Marking AllocationTotal: 1 M
Identify immutability of tuples creating new object for tuple1 while tuple2 remains (1, 2, 3), Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) False
Justification:
1. tuple1 initially references (1, 2, 3). tuple2 = tuple1 assigns tuple2 to reference the same tuple (1, 2, 3).
2. Tuples are immutable. The augmented assignment tuple1 += (4,) creates a new tuple object (1, 2, 3, 4) and rebinds tuple1 to this new object.
3. tuple2 still references the original tuple (1, 2, 3).
4. Comparing tuple1 == tuple2 evaluates (1, 2, 3, 4) == (1, 2, 3), which is False (Option B).
Chief Examiner Evaluation Report & Pitfalls:

Tuples are immutable; `+=` on a tuple creates a brand new tuple rather than modifying in-place.

7
Section A(1-Mark Questions)
1 Mark
If my_dict is a dictionary as defined below, then which of the following statements will raise an exception?
``python
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
`
(A)
my_dict.get('orange')
(B)
print(my_dict['apple', 'banana'])
(C)
my_dict['apple'] = 20
(D)
print(str(my_dict))`
CBSE Official Step-Marking AllocationTotal: 1 M
Identify that ['apple', 'banana'] looks up a 2-tuple key causing KeyError, Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) print(my_dict['apple', 'banana'])
Justification:
1. In Python, passing comma-separated values inside indexing brackets ['apple', 'banana'] creates a tuple key ('apple', 'banana').
2. Since the tuple ('apple', 'banana') is not an existing key in my_dict, Python raises a KeyError.
3. Options (A), (C), and (D) are all valid operations that do not raise errors.
Chief Examiner Evaluation Report & Pitfalls:

To look up multiple keys, you must iterate or access keys individually. `d[k1, k2]` treats `(k1, k2)` as a single compound key.

8
Section A(1-Mark Questions)
1 Mark
What does the list.remove(x) method do in Python?
(A) Removes the element at index x from the list
(B) Removes the first occurrence of value x from the list
(C) Removes all occurrences of value x from the list
(D) Removes the last occurrence of value x from the list
CBSE Official Step-Marking AllocationTotal: 1 M
State that .remove(x) removes the first occurrence of value x, Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) Removes the first occurrence of value x from the list
Justification:
- list.remove(x) searches for the value x and removes its first occurrence from the list.
- To remove by index, list.pop(index) or del list[index] is used.
- If x is not present, ValueError is raised.
Chief Examiner Evaluation Report & Pitfalls:

Distinguish `.remove(value)` (removes by value) from `.pop(index)` and `del list[index]` (remove by position).

9
Section A(1-Mark Questions)
1 Mark
If a table has one Primary key and two alternate keys, how many Candidate keys will this table have?
(A) 1
(B) 2
(C) 3
(D) 4
CBSE Official Step-Marking AllocationTotal: 1 M
Calculate Candidate Keys = Primary Key (1) + Alternate Keys (2) = 3, Option (C)
+1 M
NCERT / CBSE Model Answer
Correct Option: (C) 3
Justification:
1. In relational database theory:
Candidate Keys=Primary Key+Alternate Keys\text{Candidate Keys} = \text{Primary Key} + \text{Alternate Keys}

2. An alternate key is any candidate key that is not chosen as the primary key.
3. Given: 1 Primary Key + 2 Alternate Keys = 3 Candidate Keys (Option C).
Chief Examiner Evaluation Report & Pitfalls:

All candidate keys are eligible to be primary keys; one is selected as Primary Key and the rest become Alternate Keys.

10
Section A(1-Mark Questions)
1 Mark
Write the missing statement to complete the following code:
``python
file = open("example.txt", "r")
data = file.read(100)
____________________ # Move the file pointer to the beginning of the file
next_data = file.read(50)
file.close()
``
CBSE Official Step-Marking AllocationTotal: 1 M
Write file.seek(0) or file.seek(0, 0)
+1 M
NCERT / CBSE Model Answer
Answer: file.seek(0) (or file.seek(0, 0))
Justification:
The seek(offset, whence) method changes the current file pointer position. Passing 0 (or 0, 0) repositions the file pointer back to the byte offset 0, which is the beginning of the file.
Chief Examiner Evaluation Report & Pitfalls:

In text mode, `seek()` only supports offset relative to the beginning of the file (whence = 0).

11
Section A(1-Mark Questions)
1 Mark
State whether the following statement is True or False:
The finally block in Python is executed only if no exception occurs in the try block.
CBSE Official Step-Marking AllocationTotal: 1 M
State False and explain that finally block executes under all conditions
+1 M
NCERT / CBSE Model Answer
Answer: False
Justification:
The finally block in Python always executes, regardless of whether an exception was raised, handled, or unhandled in the try block. It is typically used for cleanup actions such as closing files or database connections.
Chief Examiner Evaluation Report & Pitfalls:

`else` block executes only if NO exception occurs; `finally` block executes ALWAYS.

12
Section A(1-Mark Questions)
1 Mark
What will be the output of the following code?
``python
c = 10
def add():
global c
c = c + 2
print(c, end='#')
add()
c = 15
print(c, end='%')
`
(A)
12%15#
(B)
15#12%
(C)
12#15%
(D)
10#15%`
CBSE Official Step-Marking AllocationTotal: 1 M
Trace function modifying global variable to 12 followed by 15%, Option (C)
+1 M
NCERT / CBSE Model Answer
Correct Option: (C) 12#15%
Justification:
1. c = 10 is defined globally.
2. Function add() declares global c, modifying global c to 10 + 2 = 12.
3. print(c, end='#') outputs 12#.
4. Next, c = 15 reassigns global c to 15.
5. print(c, end='%') outputs 15%.
6. Concatenated output: 12#15% (Option C).
Chief Examiner Evaluation Report & Pitfalls:

Notice the `end` arguments in both print statements prevent newline breaks.

13
Section A(1-Mark Questions)
1 Mark
Which SQL command can change the degree of an existing relation?
CBSE Official Step-Marking AllocationTotal: 1 M
Identify ALTER TABLE command
+1 M
NCERT / CBSE Model Answer
Answer: ALTER TABLE (or ALTER)
Justification:
- Degree of a relation is the number of attributes (columns) in the table.
- The ALTER TABLE command allows adding new columns (ADD) or dropping existing columns (DROP), thereby changing the degree of the relation.
Chief Examiner Evaluation Report & Pitfalls:

Degree = number of columns (modified by ALTER TABLE); Cardinality = number of rows (modified by INSERT/DELETE).

14
Section A(1-Mark Questions)
1 Mark
What will be the output of the query?
SELECT * FROM products WHERE product_name LIKE 'App%';
(A) Details of all products whose names start with 'App'
(B) Details of all products whose names end with 'App'
(C) Names of all products whose names start with 'App'
(D) Names of all products whose names end with 'App'
CBSE Official Step-Marking AllocationTotal: 1 M
Identify that SELECT * returns all details and 'App%' matches prefixes starting with 'App', Option (A)
+1 M
NCERT / CBSE Model Answer
Correct Option: (A) Details of all products whose names start with 'App'
Justification:
1. SELECT * selects all columns (details) of matching records, not just the names.
2. The pattern 'App%' matches any string that begins with 'App' followed by zero or more characters.
3. Therefore, it displays the details of all products whose names start with 'App' (Option A).
Chief Examiner Evaluation Report & Pitfalls:

`SELECT *` means ALL attributes (details); `SELECT product_name` would mean only product names.

15
Section A(1-Mark Questions)
1 Mark
In which datatype is the stored value padded with spaces to fit the specified length?
(A) DATE
(B) VARCHAR
(C) FLOAT
(D) CHAR
CBSE Official Step-Marking AllocationTotal: 1 M
Identify CHAR as fixed-length datatype with space padding, Option (D)
+1 M
NCERT / CBSE Model Answer
Correct Option: (D) CHAR
Justification:
CHAR(M) represents a fixed-length string. If a stored string has fewer characters than the specified length MM, MySQL right-pads it with spaces to the full length MM. In contrast, VARCHAR is variable-length and does not pad with spaces.
Chief Examiner Evaluation Report & Pitfalls:

CHAR is fixed-length (pads spaces); VARCHAR is variable-length (stores actual characters + 1-2 byte length prefix).

16
Section A(1-Mark Questions)
1 Mark
Which aggregate function can be used to find the cardinality of a table?
(A) sum()
(B) count()
(C) avg()
(D) max()
CBSE Official Step-Marking AllocationTotal: 1 M
Identify count() function for determining table cardinality, Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) count()
Justification:
- Cardinality refers to the total number of rows/tuples in a relation.
- The aggregate function COUNT(*) counts the number of rows in the table, thereby returning the table's cardinality.
Chief Examiner Evaluation Report & Pitfalls:

`COUNT(*)` returns the total row count (cardinality) including rows with NULL values.

17
Section A(1-Mark Questions)
1 Mark
Which protocol is used to transfer files over the Internet?
(A) HTTP
(B) FTP
(C) PPP
(D) HTTPS
CBSE Official Step-Marking AllocationTotal: 1 M
Select FTP (File Transfer Protocol), Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) FTP
Justification:
FTP (File Transfer Protocol) is the standard network protocol used for transferring computer files between a client and a server on a computer network. HTTP/HTTPS are used for web page hypermedia transfer.
Chief Examiner Evaluation Report & Pitfalls:

FTP operates on ports 20 and 21 for transferring binary and text files.

18
Section A(1-Mark Questions)
1 Mark
Which network device is used to connect two networks that use different protocols?
(A) Modem
(B) Gateway
(C) Switch
(D) Repeater
CBSE Official Step-Marking AllocationTotal: 1 M
Select Gateway as protocol converter between heterogeneous networks, Option (B)
+1 M
NCERT / CBSE Model Answer
Correct Option: (B) Gateway
Justification:
A Gateway operates at all layers of the OSI model and acts as a protocol converter, enabling communication between two networks running entirely different communication protocols or architectures.
Chief Examiner Evaluation Report & Pitfalls:

Router connects networks using the same protocol suite (IP); Gateway connects networks using dissimilar protocols.

19
Section A(1-Mark Questions)
1 Mark
Which switching technique breaks data into smaller packets for transmission, allowing multiple packets to share the same network resources?
CBSE Official Step-Marking AllocationTotal: 1 M
Name Packet Switching
+1 M
NCERT / CBSE Model Answer
Answer: Packet Switching
Justification:
In Packet Switching, messages are broken into discrete units called packets (each containing payload and header with source/destination addresses). Packets travel independently through dynamic routing paths across shared network infrastructure, efficiently sharing bandwidth.
Chief Examiner Evaluation Report & Pitfalls:

Contrast with Circuit Switching (dedicated end-to-end physical circuit) and Message Switching (store-and-forward of complete message).

20
Section A(1-Mark Assertion-Reason Questions)
1 Mark
Two statements are given, one labelled Assertion (A) and the other labelled Reason (R):
Assertion (A): Positional arguments in Python functions must be passed in the exact order in which they are defined in the function signature.
Reasoning (R): This is because Python functions automatically assign default values to positional arguments.
Select the correct answer:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True
CBSE Official Step-Marking AllocationTotal: 1 M
Identify that A is True but R is False, Option (C)
+1 M
NCERT / CBSE Model Answer
Correct Option: (C) A is True but R is False
Justification:
1. Assertion (A) is True: Positional arguments are bound to parameters based on their position/order in the function call.
2. Reasoning (R) is False: Positional arguments without default values are mandatory; Python does not automatically assign default values to positional arguments unless explicitly specified in the function definition header.
Chief Examiner Evaluation Report & Pitfalls:

Positional arguments have no default values unless defined with `param=default_val`. Missing a positional argument raises `TypeError`.

21
Section A(1-Mark Assertion-Reason Questions)
1 Mark
Two statements are given, one labelled Assertion (A) and the other labelled Reason (R):
Assertion (A): In SQL, a foreign key can accept duplicate values.
Reasoning (R): A foreign key must uniquely identify each record in the child table.
Select the correct answer:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True
CBSE Official Step-Marking AllocationTotal: 1 M
Recognize that foreign keys permit duplicates and do not uniquely identify child table records, Option (C)
+1 M
NCERT / CBSE Model Answer
Correct Option: (C) A is True but R is False
Justification:
1. Assertion (A) is True: A foreign key establishes a 1-to-many relationship, so multiple child table records can reference the same parent table primary key value (e.g., multiple employees working in the same department).
2. Reasoning (R) is False: A foreign key does not uniquely identify records in the child table; the child table's own primary key uniquely identifies its records.
Chief Examiner Evaluation Report & Pitfalls:

Primary keys must be unique and NOT NULL. Foreign keys can have duplicates and can also accept NULL values.

22
Section B(2-Mark Questions)
2 Marks
How is a mutable object different from an immutable object in Python? Identify one mutable object and one immutable object from the following:
(1, 2), [1, 2], {1: 1, 2: 2}, '123'
CBSE Official Step-Marking AllocationTotal: 2 M
Define difference between mutable and immutable objects (1.0M)
+1 M
Identify one mutable object ([1,2] or {1:1,2:2}) and one immutable object ((1,2) or '123') (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
1. Difference [1 Mark]:
- Mutable objects: Objects whose state or content can be changed in-place after creation without changing their memory identity id() (e.g., lists, dictionaries, sets).
- Immutable objects: Objects whose content cannot be changed once created; any modification creates a new object in memory (e.g., integers, floats, strings, tuples).
2. Identification [1 Mark (0.5M each)]:
- Mutable object (Any one): [1, 2] (list) OR {1: 1, 2: 2} (dictionary).
- Immutable object (Any one): (1, 2) (tuple) OR '123' (string).
Chief Examiner Evaluation Report & Pitfalls:

Strings, tuples, and numeric types are immutable; lists, dictionaries, and sets are mutable.

23
Section B(2-Mark Questions)
2 Marks
Give two examples of each of the following:
(I) Arithmetic operators
(II) Relational operators
CBSE Official Step-Marking AllocationTotal: 2 M
Give two valid arithmetic operators (e.g., +, *, //) (1.0M)
+1 M
Give two valid relational operators (e.g., ==, >=) (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
(I) Arithmetic Operators (Any two) [1 Mark]:
- + (Addition), - (Subtraction), (Multiplication), / (Division), // (Floor Division), % (Modulus), * (Exponentiation).
(II) Relational (Comparison) Operators (Any two) [1 Mark]:
- == (Equal to), != (Not equal to), > (Greater than), < (Less than), >= (Greater than or equal to), <= (Less than or equal to).
Chief Examiner Evaluation Report & Pitfalls:

Do not confuse assignment operator `=` with relational equality operator `==`.

24
Section B(2-Mark Questions)
Internal Choice (OR)2 Marks
If L1 = [1, 2, 3, 2, 1, 2, 4, 2, ...] and L2 = [10, 20, 30, ...], then (answer using built-in functions/methods only):
(I)
A) Write a statement to count the occurrences of 4 in L1.
OR
B) Write a statement to sort L1 in ascending order in-place.
(II)
A) Write a statement to append all elements of L2 at the end of L1.
OR
B) Write a statement to reverse the elements of L2 in-place.
CBSE Official Step-Marking AllocationTotal: 2 M
Part (I): Write L1.count(4) OR L1.sort() (1.0M)
+1 M
Part (II): Write L1.extend(L2) OR L2.reverse() (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
(I) [1 Mark]:
- A) L1.count(4)
OR
- B) L1.sort()
(II) [1 Mark]:
- A) L1.extend(L2)
OR
- B) L2.reverse()
Chief Examiner Evaluation Report & Pitfalls:

`L1.append(L2)` adds `L2` as a nested sublist; `L1.extend(L2)` adds each element individually.

25
Section B(2-Mark Questions)
2 Marks
Identify the correct output(s) of the following code. Also write the minimum and maximum possible values of the variable b:
``python
import random
a = "Wisdom"
b = random.randint(1, 6)
for i in range(b):
print(a[i], end="*")
print()
`
Possible Outputs:
(A)
Wis*
(B)
Wisdom
(C)
W*
(D)
isd*`
CBSE Official Step-Marking AllocationTotal: 2 M
State min value = 1 and max value = 6 (1.0M)
+1 M
Identify valid outputs (A) and (C) [and (B)] starting from index 0 (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
1. random.randint(1, 6) generates an integer bb where 1≤b≤61 \le b \le 6 (both endpoints inclusive).
- Minimum possible value of b: 1
- Maximum possible value of b: 6 [1 Mark]
2. Loop for i in range(b) runs from index 0 to b - 1:
- When b=1b = 1: prints a[0] + ""   ⟹  \implies W (Option C)
- When b=2b = 2: prints Wi
- When b=3b = 3: prints Wis* (Option A)
- When b=4b = 4: prints Wisd
- When b=5b = 5: prints Wisdo*
- When b=6b = 6: prints Wisdom (Option B)
3. Correct generated outputs: (A), (B), and (C) (any of these can be generated). Option (D) cannot be generated because slicing always starts at index 0 (W).
Chief Examiner Evaluation Report & Pitfalls:

`randint(a, b)` includes BOTH $a$ and $b$. Slicing from `range(b)` always begins at index 0 ('W').

26
Section B(2-Mark Questions)
2 Marks
The code provided below is intended to swap the first and last elements of a given tuple. However, there are syntax and logical errors in the code. Rewrite it after removing all errors. Underline all corrections made:
``python
def swap_first_last(tup):
if len(tup) < 2:
return tup
new_tup = tup[-1] + tup[1:-1] + tup[0] # Errors here
return new_tup
result = swap_first_last((1, 2, 3, 4))
print("Swapped tuple:", result)
``
CBSE Official Step-Marking AllocationTotal: 2 M
Correct tuple concatenation with single-element comma syntax: (tup[-1],) (1.0M)
+1 M
Correct trailing element (tup[0],) and return valid swapped tuple (1.0M)
+1 M
NCERT / CBSE Model Answer
Corrected Code:
``python
def swap_first_last(tup):
if len(tup) < 2:
return tup
new_tup = (tup[-1],) + tup[1:-1] + (tup[0],)
return new_tup
result = swap_first_last((1, 2, 3, 4))
print("Swapped tuple:", result)
`
Corrections Explained:
1.
tup[-1] is an int, not a tuple. Concatenating an int with a slice tup[1:-1] raises a TypeError. It must be made a single-element tuple: (tup[-1],).
2. Similarly,
tup[0] is an int. It must be written as a single-element tuple: (tup[0],).
3. A single element tuple requires a trailing comma:
(item,)`.
Chief Examiner Evaluation Report & Pitfalls:

A single element in parentheses without a comma `(x)` is evaluated as an integer/expression, NOT a tuple. `(x,)` defines a 1-tuple.

27
Section B(2-Mark Questions)
Internal Choice (OR)2 Marks
(I)
A) What constraint should be applied on a table column so that duplicate values are not allowed in that column, but NULL is allowed?
OR
B) What constraint should be applied on a table column so that NULL values are not allowed?
(II)
A) Write the SQL command to drop the Primary Key constraint from table MOBILE.
OR
B) Write the SQL command to add a Primary Key on column M_ID in existing table MOBILE.
CBSE Official Step-Marking AllocationTotal: 2 M
Part (I): Identify UNIQUE or NOT NULL constraint (1.0M)
+1 M
Part (II): Write ALTER TABLE command dropping or adding primary key (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
(I) [1 Mark]:
- A) UNIQUE constraint.
OR
- B) NOT NULL constraint.
(II) [1 Mark]:
- A) ALTER TABLE MOBILE DROP PRIMARY KEY;
OR
- B) ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
Chief Examiner Evaluation Report & Pitfalls:

`UNIQUE` allows NULLs but disallows duplicates. `PRIMARY KEY` disallows both duplicates and NULLs.

28
Section B(2-Mark Questions)
Internal Choice (OR)2 Marks
A) List one advantage and one disadvantage of Star Topology.
OR
B) Expand the term SMTP. What is the use of SMTP?
CBSE Official Step-Marking AllocationTotal: 2 M
Part A: One advantage (easy expansion/fault isolation) (1.0M) and one disadvantage (central hub failure) (1.0M)
+2 M
NCERT / CBSE Model Answer
Solution for A:
- Advantage [1 Mark]: Easy to install, configure, and expand; failure of a single node or cable does not affect the rest of the network.
- Disadvantage [1 Mark]: Central point of failure: if the central hub or switch fails, the entire network goes down; requires more cable length than bus topology.

Alternative Option Solution:

- Expansion [1 Mark]: Simple Mail Transfer Protocol.
- Use [1 Mark]: SMTP is used for sending / transmitting outgoing emails from a client email application to a mail server, or between mail servers across the Internet.
Chief Examiner Evaluation Report & Pitfalls:

SMTP is used to SEND mail; POP3/IMAP are used to RETRIEVE/DOWNLOAD mail.

29
Section C(3-Mark Questions)
Internal Choice (OR)3 Marks
A) Write a Python function show() that reads a text file "Emails.txt" and displays all words containing '@cmail'.
OR
B) Write a Python function long_words() that reads a text file "Story.txt" and finds and displays all words longer than 5 characters along with the total count of such words.
CBSE Official Step-Marking AllocationTotal: 3 M
Open file in read mode ('r') and close file properly (1.0M)
+1 M
Read data and split into words using .split() (1.0M)
+1 M
Check condition ('@cmail' in word or len(word) > 5) and display output (1.0M)
+1 M
NCERT / CBSE Model Answer
Solution for A:
``python
def show():
f = open("Emails.txt", 'r')
data = f.read()
words = data.split()
for word in words:
if '@cmail' in word:
print(word, end=' ')
f.close()
`

Alternative Option Solution:

`python
def long_words():
f = open("Story.txt", 'r')
data = f.read()
words = data.split()
count = 0
for word in words:
if len(word) > 5:
print(word)
count += 1
print("Total words with length > 5:", count)
f.close()
``
Chief Examiner Evaluation Report & Pitfalls:

Using `f.read().split()` splits across all whitespace (spaces, tabs, newlines), avoiding issues with line-by-line reading.

30
Section C(3-Mark Questions)
3 Marks
You have a stack named BooksStack that contains records of books. Each book record is represented as a list: [book_title, author_name, publication_year].
Write Python functions to perform the following operations on BooksStack:
(I) push_book(BooksStack, new_book) to push a book onto the stack.
(II) pop_book(BooksStack) to pop and return a book from the stack. Display 'Underflow' if the stack is empty.
(III) peep(BooksStack) to display the topmost book without removing it. Display 'None' if the stack is empty.
CBSE Official Step-Marking AllocationTotal: 3 M
Function push_book using .append() (1.0M)
+1 M
Function pop_book checking underflow condition and returning .pop() (1.0M)
+1 M
Function peep checking empty stack and displaying top element BooksStack[-1] (1.0M)
+1 M
NCERT / CBSE Model Answer
Python Code:
``python
def push_book(BooksStack, new_book):
BooksStack.append(new_book)
def pop_book(BooksStack):
if not BooksStack: # or len(BooksStack) == 0
print("Underflow")
return None
else:
return BooksStack.pop()
def peep(BooksStack):
if not BooksStack:
print("None")
else:
print("Top Book:", BooksStack[-1])
``
Chief Examiner Evaluation Report & Pitfalls:

In Python list implementation of stacks, `append()` represents `push` and `pop()` represents `pop`. Top of stack is index `-1`.

31
Section C(3-Mark Questions)
Internal Choice (OR)3 Marks
A) Predict the output of the following code:
``python
d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
for key in d:
str1 = str1 + str(d[key]) + "@" + "\n"
str2 = str1[:-1]
print(str2)
`
OR
B) Predict the output of the following code:
`python
for i in range(1, 4):
for j in range(1, i + 1):
print(j, end=" #")
print()
``
CBSE Official Step-Marking AllocationTotal: 3 M
Part A: Line 1: 15@ (1.0M)
+1 M
Part A: Line 2: 7@ (1.0M)
+1 M
Part A: Line 3: 9 (1.0M) OR Part B: Each row printed correctly (1M x 3)
+1 M
NCERT / CBSE Model Answer
Solution for A:
``
15@
7@
9@
`
(Or if last newline is sliced:
15@\n7@\n9 printed across lines:)
Line 1:
15@
Line 2:
7@
Line 3:
9

Alternative Option Solution:

`
1 #
1 #2 #
1 #2 #3 #
``
Chief Examiner Evaluation Report & Pitfalls:

Trace loop iterations carefully; note that `end=" #"` places the symbol after the printed number.

32
Section D(4-Mark Questions)
4 Marks
Consider the table ORDERS with schema (O_Id, C_Name, Product, Quantity, Price).
Write SQL queries for the following:
(I) Display product names and total quantity ordered for products where total quantity is at least 5.
(II) Display all details of orders in descending order of Price.
(III) Display all unique customer names from the orders table.
(IV) Calculate the total price of all orders where Quantity is NULL.
CBSE Official Step-Marking AllocationTotal: 4 M
Query (I): GROUP BY Product HAVING SUM(Quantity) >= 5 (1.0M)
+1 M
Query (II): ORDER BY Price DESC (1.0M)
+1 M
Query (III): SELECT DISTINCT C_Name (1.0M)
+1 M
Query (IV): WHERE Quantity IS NULL with SUM(Price) (1.0M)
+1 M
NCERT / CBSE Model Answer
SQL Queries:
``sql
-- (I)
SELECT Product, SUM(Quantity)
FROM ORDERS
GROUP BY Product
HAVING SUM(Quantity) >= 5;
-- (II)
SELECT *
FROM ORDERS
ORDER BY Price DESC;
-- (III)
SELECT DISTINCT C_Name
FROM ORDERS;
-- (IV)
SELECT SUM(Price) AS Total_Price
FROM ORDERS
WHERE Quantity IS NULL;
``
Chief Examiner Evaluation Report & Pitfalls:

Use `HAVING` with aggregate functions (`SUM`), never `WHERE`. Use `IS NULL` for NULL checking, never `= NULL`.

33
Section D(4-Mark Questions)
4 Marks
A CSV file "Happiness.csv" contains records with: [Country, Population, Sample_Size, Happiness_Score].
Write Python functions to:
(I) Read and display all records where Population is greater than 5,000,000 (skip header row).
(II) Accept country name, population, sample size, and happiness score from user and write as a new row to "Happiness.csv".
CBSE Official Step-Marking AllocationTotal: 4 M
Part (I): Open with csv.reader, use next() to skip header, filter int(row[1]) > 5000000 (2.0M)
+2 M
Part (II): Open in append mode ('a'), use csv.writer, write row with writerow() (2.0M)
+2 M
NCERT / CBSE Model Answer
Python Code:
``python
import csv

(I) Read records with Population > 5,000,000

def show_large_countries():
with open("Happiness.csv", 'r', newline='') as f:
reader = csv.reader(f)
next(reader, None) # Skip header row
for row in reader:
if row and int(row[1]) > 5000000:
print(row)

(II) Append new record to CSV

def add_country():
country = input("Enter Country Name: ")
pop = int(input("Enter Population: "))
sample = int(input("Enter Sample Size: "))
score = float(input("Enter Happiness Score: "))

with open("Happiness.csv", 'a', newline='') as f:
writer = csv.writer(f)
writer.writerow([country, pop, sample, score])
print("Record successfully added.")
``
Chief Examiner Evaluation Report & Pitfalls:

Always specify `newline=''` when opening CSV files in Python to prevent extra blank lines on Windows.

34
Section D(4-Mark Questions)
4 Marks
Consider tables FACULTY (F_ID, FName, LName, Salary) and COURSES (C_ID, CName, Fees, F_ID).
Write SQL queries for:
(I) Display all details of faculty members along with courses taught by them for faculty members earning less than 12000.
(II) Display all courses whose fees are between 20000 and 50000.
(III) Increase the fees by 500 for all courses having 'Computer' anywhere in their name.
(IV) Display course name and faculty first name for all courses.
CBSE Official Step-Marking AllocationTotal: 4 M
Query (I): Table join with join condition and Salary < 12000 (1.0M)
+1 M
Query (II): BETWEEN 20000 AND 50000 (1.0M)
+1 M
Query (III): UPDATE with SET and LIKE '%Computer%' (1.0M)
+1 M
Query (IV): Equi-join selecting CName and FName (1.0M)
+1 M
NCERT / CBSE Model Answer
SQL Queries:
``sql
-- (I)
SELECT *
FROM FACULTY F, COURSES C
WHERE F.F_ID = C.F_ID AND F.Salary < 12000;
-- (Or: SELECT * FROM FACULTY NATURAL JOIN COURSES WHERE Salary < 12000;)
-- (II)
SELECT *
FROM COURSES
WHERE Fees BETWEEN 20000 AND 50000;
-- (III)
UPDATE COURSES
SET Fees = Fees + 500
WHERE CName LIKE '%Computer%';
-- (IV)
SELECT C.CName, F.FName
FROM COURSES C, FACULTY F
WHERE C.F_ID = F.F_ID;
``
Chief Examiner Evaluation Report & Pitfalls:

Always include the join condition (`F.F_ID = C.F_ID`) when querying multiple tables to avoid an unconstrained Cartesian product.

35
Section D(4-Mark Questions)
4 Marks
A table STATIONERY in MySQL database ITEMDB has fields: itemNo (int), itemName (varchar), price (float), qty (int).
Write a Python program using mysql.connector to connect to ITEMDB (user: 'root', password: 'Pencil') and perform the following:
- Accept item details from user and insert into STATIONERY.
- Fetch and display all records where price > 100.
CBSE Official Step-Marking AllocationTotal: 4 M
Establish database connection and create cursor (1.0M)
+1 M
Execute parameterized INSERT query and call mydb.commit() (1.5M)
+1.5 M
Execute SELECT query, retrieve records with cursor.fetchall(), and display (1.5M)
+1.5 M
NCERT / CBSE Model Answer
Python Code:
``python
import mysql.connector as mycon
def manage_stationery():
mydb = mycon.connect(
host="localhost",
user="root",
passwd="Pencil",
database="ITEMDB"
)
cursor = mydb.cursor()

Insert new record

no = int(input("Enter Item Number: "))
nm = input("Enter Item Name: ")
pr = float(input("Enter Price: "))
qt = int(input("Enter Quantity: "))

sql_insert = "INSERT INTO STATIONERY VALUES (%s, %s, %s, %s)"
cursor.execute(sql_insert, (no, nm, pr, qt))
mydb.commit()
print("Item added successfully.")

Display records with price > 100

cursor.execute("SELECT * FROM STATIONERY WHERE price > 100")
records = cursor.fetchall()
print("Items with Price > 100:")
for row in records:
print(row)

cursor.close()
mydb.close()
``
Chief Examiner Evaluation Report & Pitfalls:

Do not forget `mydb.commit()` after data manipulation (INSERT/UPDATE/DELETE) commands in Python-MySQL connectivity.

36
Section E(5-Mark Questions)
5 Marks
A recruitment agency needs to manage candidate records in a binary file "candidates.dat". Each record is a list: [candidate_id, candidate_name, designation, salary].
Write Python functions to:
(I) input_candidates(): Accept NN candidate records from the user and write them into "candidates.dat" using the pickle module. [2.5 Marks]
(II) search_candidate(cand_id): Read "candidates.dat" and display the details of the candidate with the given cand_id. If not found, display 'Candidate not found'. [2.5 Marks]
CBSE Official Step-Marking AllocationTotal: 5 M
Part (I): Open binary file in append mode ('ab'), collect data, and write using pickle.dump() (2.5M)
+2.5 M
Part (II): Open in read binary ('rb'), loop with try-except EOFError, search by ID, and handle not found case (2.5M)
+2.5 M
NCERT / CBSE Model Answer
Python Code:
``python
import pickle
import os
def input_candidates():
candidates = []
n = int(input("Enter number of candidates to add: "))
for i in range(n):
cid = int(input("Enter Candidate ID: "))
name = input("Enter Candidate Name: ")
desig = input("Enter Designation: ")
salary = float(input("Enter Salary: "))
candidates.append([cid, name, desig, salary])

with open("candidates.dat", "ab") as f:
for cand in candidates:
pickle.dump(cand, f)
print("Records written successfully.")
def search_candidate(cand_id):
found = False
if not os.path.exists("candidates.dat"):
print("File does not exist.")
return

with open("candidates.dat", "rb") as f:
while True:
try:
record = pickle.load(f)
if record[0] == cand_id:
print("Candidate Found:", record)
found = True
break
except EOFError:
break

if not found:
print("Candidate not found")
``
Chief Examiner Evaluation Report & Pitfalls:

In binary file processing, always catch `EOFError` to detect the end of the file when using `pickle.load()` in a loop.

37
Section E(5-Mark Case Study (Computer Networks))
5 Marks
Event Horizon Enterprises is planning to set up its India campus in Mumbai with its head office in Delhi. The Mumbai campus has four blocks/buildings:
- Admin Block: 110 Computers
- Finance Block: 35 Computers
- Design Block: 25 Computers
- HR Block: 15 Computers
Distances between blocks:
- Admin to Finance: 40 m
- Admin to Design: 120 m
- Admin to HR: 90 m
- Finance to Design: 80 m
- Finance to HR: 150 m
- Design to HR: 70 m
- Mumbai Campus to Delhi Head Office: 1400 km
Answer the following questions:
(I) Suggest the most suitable block to install the server in the Mumbai campus with suitable justification. [1 Mark]
(II) Suggest the best network device to connect all computers within each block. [1 Mark]
(III) Draw the most economical cable layout to connect all four blocks in Mumbai campus. [1 Mark]
(IV) Suggest the most suitable transmission medium to connect Mumbai campus with Delhi head office. [1 Mark]
(V) The company is planning to host online video conferences with international clients. Suggest an appropriate protocol for real-time video/voice communication. [1 Mark]
CBSE Official Step-Marking AllocationTotal: 5 M
Subpart (I): Suggest Admin block citing maximum computers (1.0M)
+1 M
Subpart (II): Suggest Switch/Hub for connecting computers within blocks (1.0M)
+1 M
Subpart (III): Draw/specify minimum spanning tree cable layout (Star/Bus) (1.0M)
+1 M
Subpart (IV): Suggest Satellite Link / Optical Fiber for 1400 km link (1.0M)
+1 M
Subpart (V): Name VoIP / RTP / SIP for video conferencing (1.0M)
+1 M
NCERT / CBSE Model Answer
Step-by-step Solution:
(I) Server Location [1 Mark]:
- Admin Block.
- Justification: According to the 80-20 networking rule, the server should be placed in the building with the maximum number of computers (Admin Block has 110 computers). This minimizes intra-campus network traffic and reduces transmission delays.
(II) Device for Intra-Block Connectivity [1 Mark]:
- Switch (or Hub).
- A switch operates at the data link layer and provides intelligent packet forwarding to connect multiple computers within each block.
(III) Economical Cable Layout (Star/Bus Topology) [1 Mark]:
- Connect blocks using minimum spanning tree based on distances:
- Admin to Finance: 40 m40\text{ m}
- Admin to HR: 90 m90\text{ m} (or Design to HR 70 m70\text{ m})
- Finance to Design: 80 m80\text{ m}
- Total cable length: 40 m+80 m+70 m=190 m40\text{ m} + 80\text{ m} + 70\text{ m} = 190\text{ m}.
- Layout: Star topology with Admin as hub, or Bus topology connecting Admin — Finance — Design — HR.
(IV) Long-Distance Transmission Medium [1 Mark]:
- Satellite Link (or Optical Fibre / Microwave link).
- Because the distance between Mumbai and Delhi is 1400 km1400\text{ km} across geographical terrain, a high-bandwidth satellite link or dedicated terrestrial optical fiber lease line is optimal.
(V) Protocol for Real-Time Video Conference [1 Mark]:
- VoIP (Voice over Internet Protocol) / RTP (Real-time Transport Protocol) / SIP (Session Initiation Protocol).
Chief Examiner Evaluation Report & Pitfalls:

Server location is always justified by the 80-20 rule: place server in the block having the largest number of computers.