CBSE Class 12 Computer Science Practice Paper - Set 2
CBSE Class 12 Computer Science Practice Paper - Set 2
SECTION A (1 Mark each)
Select the most appropriate option.
Which of the following is an immutable data type in Python?
a) List b) Dictionary c) Set d) String
Which SQL constraint ensures that all values in a column are different and not null?
a) UNIQUE b) PRIMARY KEY c) DISTINCT d) FOREIGN KEY
Assertion (A): CSV files are text files that store data in a tabular format.
Reason (R): The default delimiter in a CSV file is a tab character \t.
a) Both A and R are true.
b) A is true, R is false.
c) A is false, R is true.
d) Both A and R are false.
Which function is used to return the current position of the file pointer?
a) seek() b) tell() c) current() d) pos()
Which topology requires a central controller or hub?
a) Bus b) Star c) Ring d) Mesh
What is the output of the following?
Pythont = (1, 2, [3, 4]) t[2][0] = 10 print(t)a) Error b)
(1, 2, [10, 4])c)(1, 2, [3, 4])d)(1, 2, 10, 4)Which keyword is used to sort the result in SQL?
a) SORT BY b) ORDER BY c) GROUP BY d) ALIGN BY
Identify the invalid variable name:
a) _Total b) Total_Marks c) 12Total d) Total
Which device amplifies the signal to extend the range of a network?
a) Modem b) Repeater c) Gateway d) Router
In Python SQL connectivity, what is the role of the commit() function?
a) To fetch data b) To save changes to the database c) To close the connection d) To execute the query
(Q11-Q21 cover logic questions on
mathmodule,picklemodule, and boolean algebra).
SECTION B (2 Marks each)
Very Short Answer Type
Predict the output of the following code. Justify your answer.
Pythonimport random val = [10, 20, 30, 40] begin = random.randint(0, 1) end = random.randint(2, 3) for i in range(begin, end + 1): print(val[i], end="-")Rewrite the following code using a
forloop instead of awhileloop:Pythoni = 100 while i > 0: print(i) i -= 5Explain the difference between
read(n)andreadline()in Python file handling.Write a SQL query to display the structure (columns and data types) of a table named
INVENTORY.Differentiate between URL and Domain Name with examples.
What will be the output of the following?
Pythondef change(P, Q=30): P = P + Q Q = P - Q print(P, "#", Q) return P R = 150 S = 100 R = change(R, S) print(R, "#", S)OR Option: Differentiate between
fetchmany(size)andfetchall()methods.
SECTION C (3 Marks each)
Short Answer Type
Database Querying:
Consider table SMARTPHONE (Model, Brand, Price, MfgDate).
i) Display the Brand and Average Price of phones, grouped by Brand.
ii) Display the details of phones manufactured in the year 2024.
iii) Delete the record where the Model is "X-Phone".
List Manipulation:
Write a function Swap_Half(L) in Python that takes a list of integers as a parameter and swaps the first half of the list elements with the second half.
Example: If L = [1, 2, 3, 4, 5, 6], Output L = [4, 5, 6, 1, 2, 3]. (Assume even number of elements).
Text File Handling:
Write a function Display_Lines() that reads a text file DIARY.TXT and prints only those lines that do not start with the letter 'T' (case insensitive).
SECTION D (4 Marks each)
Long Answer Type
Binary File (Pickle) with Search:
Create a Python program with two functions:
a) Create_File(): Accepts EmpID, Name, and Designation from the user and writes them into a binary file EMP.DAT using pickle.
b) Search_Emp(id): Accepts an EmpID, searches for it in EMP.DAT, and displays the Name and Designation. If not found, display "Employee not found".
Stack Implementation:
Write the functions Push(Book) and Pop(Book) where Book is a list of dictionaries. Each dictionary contains {'BookID': ..., 'Title': ...}.
Push: Add a book dictionary to the stack.Pop: Remove the last book added. If the stack is empty, print "Underflow".
CSV File Handling:
Write a function Total_Sales() in Python that reads a CSV file SALES.CSV containing (Item, Qty, PricePerUnit). The function should calculate the total sales amount (Qty * PricePerUnit) for every row and print the Grand Total of all sales at the end.
Networks Case Study (Education Campus):
"Zenith University" has four blocks: Admin, Science, Arts, Commerce.
Distance Admin to Science: 50m
Distance Admin to Arts: 60m
Distance Admin to Commerce: 150m
Distance Science to Commerce: 200m
Computers: Admin (10), Science (150), Arts (50), Commerce (20).
Questions:
i) Suggest the most economic cable layout.
ii) Where should the Server be placed? Justify.
iii) The university wants to link its campus in New Delhi to its campus in London. Which transmission medium is best?
iv) Which device should be placed in the Science block to connect all 150 computers efficiently?
SECTION E (5 Marks each)
Competency/Case-based Questions
Case Study - SQL (Relational Algebra & Joins):
Table CLIENT (ClientID, CName, City, ID)
Table BILL (BillNo, BillDate, Amount, ClientID)
i) Identify the Foreign Key in the BILL table.
ii) A user executes DELETE FROM CLIENT WHERE ClientID = 101; but gets an error. Explain the likely reason (Referential Integrity).
iii) Write a query to display Client Name, Bill Date, and Amount for all bills where Amount > 5000.
iv) If the CLIENT table has 4 rows and BILL table has 3 rows, what will be the Degree and Cardinality of the Cartesian Product of these two tables?
Case Study - Python Exception Handling & Logic:
Consider the code below intended to calculate the average of marks entered by a user:
Pythontotal = 0 count = 0 while True: data = input("Enter marks (or 'q' to quit): ") if data == 'q': break # Missing Code Block A print("Average:", total/count)i) Write the code for "Missing Code Block A" to convert input to integer, add to total, and increment count.
ii) Use a try-except block inside Block A to handle the case where the user accidentally types "ten" (non-numeric) instead of 10, ensuring the program doesn't crash.
iii) What runtime error will occur at the last line (print) if the user enters 'q' immediately without entering any marks?
Comments
Post a Comment