Sample paper · Class 12 · CBSE · Science Computer Science
Computer Science · Sample Paper 4
CBSE board pattern (083), Class 12 syllabus — all chapters, a fresh set of questions. Programming language: Python; queries in SQL.
37 questions · 70 marks · 180 minutes
General instructions
- This paper has 37 questions in five sections, A to E. All questions are compulsory.
- Section A — Q1 to Q21: 1 mark each.
- Section B — Q22 to Q28: 2 marks each.
- Section C — Q29 to Q31: 3 marks each.
- Section D — Q32 to Q35: 4 marks each.
- Section E — Q36 and Q37: 5 marks each.
- Internal choice is given in Q23, Q29, Q34 and Q37. Answer only one alternative.
- All programming questions are to be answered in Python; queries in SQL (MySQL).
Section A · Objective
Questions 1–21 carry 1 mark each.
- Question 11 mark
In a relational database, data is organised in
- A.trees
- B.tables (relations)
- C.graphs
- D.files only
- Question 21 mark
All candidate keys other than the primary key are
- A.foreign keys
- B.alternate keys
- C.composite keys
- D.super keys
- Question 31 mark
The best-case time complexity of linear search is
- A.O(1)
- B.O(n)
- C.O(log n)
- D.O(n²)
- Question 41 mark
Which keyword handles an exception in Python?
- A.catch
- B.except
- C.error
- D.handle
- Question 51 mark
Which exception is raised for an invalid list index?
- A.KeyError
- B.IndexError
- C.ValueError
- D.NameError
- Question 61 mark
Which method writes a list of strings to a text file?
- A.write()
- B.writelines()
- C.dump()
- D.append()
- Question 71 mark
What does f.tell() return?
- A.file size
- B.current position of the file pointer
- C.number of lines
- D.file name
- Question 81 mark
Which operation returns the top element without removing it?
- A.push
- B.pop
- C.peek
- D.enqueue
- Question 91 mark
The postfix expression '3 4 + 2 *' evaluates to
- A.14
- B.11
- C.10
- D.24
- Question 101 mark
A queue in which insertion and deletion can happen at both ends is a
- A.circular queue
- B.deque
- C.priority queue
- D.stack
- Question 111 mark
Which sorting algorithm builds the final sorted list one item at a time by inserting into position?
- A.selection sort
- B.insertion sort
- C.bubble sort
- D.quick sort
- Question 121 mark
Linear search can be used on
- A.sorted lists only
- B.unsorted lists only
- C.both sorted and unsorted lists
- D.dictionaries only
- Question 131 mark
Data that is collected for the first time by the user is
- A.secondary data
- B.primary data
- C.metadata
- D.derived data
- Question 141 mark
Which command creates a new table?
- A.CREATE TABLE
- B.MAKE TABLE
- C.NEW TABLE
- D.INSERT TABLE
- Question 151 mark
Which function counts non-NULL values in a column?
- A.COUNT(column)
- B.SUM(column)
- C.COUNT(*)
- D.MAX(column)
- Question 161 mark
Which device connects multiple computers in a LAN and forwards data only to the intended device?
- A.hub
- B.switch
- C.modem
- D.repeater
- Question 171 mark
The internet is an example of a
- A.LAN
- B.MAN
- C.WAN
- D.PAN
- Question 181 mark
Which protocol is used to receive email?
- A.SMTP
- B.POP3
- C.HTTP
- D.FTP
- Question 191 mark
A program that blocks unauthorised access to a network is a
- A.virus
- B.firewall
- C.cookie
- D.browser
- Question 201 mark
Assertion (A): A stack is used to check balanced parentheses.
Reason (R): The last opened bracket must be closed first (LIFO).
- A.Both Assertion (A) and Reason (R) are true, and R is the correct explanation of A.
- B.Both Assertion (A) and Reason (R) are true, but R is not the correct explanation of A.
- C.Assertion (A) is true, but Reason (R) is false.
- D.Assertion (A) is false, but Reason (R) is true.
- Question 211 mark
Assertion (A): The HAVING clause is used with GROUP BY.
Reason (R): HAVING applies conditions to groups.
- A.Both Assertion (A) and Reason (R) are true, and R is the correct explanation of A.
- B.Both Assertion (A) and Reason (R) are true, but R is not the correct explanation of A.
- C.Assertion (A) is true, but Reason (R) is false.
- D.Assertion (A) is false, but Reason (R) is true.
Section B · Very short answer
Questions 22–28 carry 2 marks each.
- Question 222 marks
Differentiate between a primary key and a foreign key.
- Question 232 marks
Write the output:
try: d = {'a': 1} print(d['b']) except KeyError: print('Missing key') else: print('Found') OR
Question 232 marksWhat is the difference between raise and assert in Python?
- Question 242 marks
Write a function
count_vowels()that counts the vowels in a text filestory.txt. - Question 252 marks
Evaluate the postfix expression 6 2 / 3 + 4 * using a stack, showing the stack after each operator.
- Question 262 marks
Differentiate between COUNT(*) and COUNT(column_name).
- Question 272 marks
Expand: (i) HTTP (ii) FTP (iii) IP (iv) Wi-Fi.
- Question 282 marks
What is a cookie? Give one advantage and one risk.
Section C · Short answer
Questions 29–31 carry 3 marks each.
- Question 293 marks
Write a Python function
push_even(L, stack)that pushes all even numbers from list L onto a stack, andpop_all(stack)that pops and prints all elements. OR
Question 293 marksShow the list after each pass of selection sort on [29, 10, 14, 37, 13].
- Question 303 marks
Write a program to read a CSV file
emp.csv(columns: name, dept, salary) and display the total salary of each department. - Question 313 marks
Explain bandwidth, data transfer rate and IP address.
Section D · Long answer
Questions 32–35 carry 4 marks each.
- Question 324 marks
Consider the table EMPLOYEE:
| EID | Name | Dept | Salary | City | |---|---|---|---|---| | E1 | Ravi | Sales | 40000 | Pune | | E2 | Neha | HR | 55000 | Delhi | | E3 | Amit | Sales | 35000 | Delhi | | E4 | Riya | IT | 70000 | Pune |
Write SQL queries to:
(i) display the names of employees earning more than 40000, (ii) display the maximum salary in each department, (iii) display the details of employees from Delhi in descending order of salary, (iv) change the city of E3 to 'Mumbai'.
- Question 334 marks
Write a program to search a binary file
student.dat(records [roll, name, marks] stored using pickle) for a roll number entered by the user and display the record or 'Not found'. - Question 344 marks
Write Python code using mysql.connector to create a table ITEMS(ItemID INT PRIMARY KEY, Name VARCHAR(30), Price FLOAT) in database
shop. OR
Question 344 marksExplain the terms relation, attribute, tuple, domain and degree with an example.
- Question 354 marks
Differentiate between a hub, a switch and a router, and explain the role of a gateway.
Section E · Long answer
Questions 36 and 37 carry 5 marks each.
- Question 365 marks
Case study — Hospital network expansion. A chain of clinics in Lucknow has four buildings: OPD, LAB, PHARMACY and ADMIN. Distances: OPD–LAB 50 m, OPD–PHARMACY 70 m, OPD–ADMIN 110 m, LAB–PHARMACY 40 m, LAB–ADMIN 90 m, PHARMACY–ADMIN 60 m. Computers: OPD 60, LAB 35, PHARMACY 20, ADMIN 15.
(i) Where should the server be placed? Why? (1 mark)
(ii) Suggest a cable layout for the buildings. (1 mark)
(iii) Where would you place a repeater? (1 mark)
(iv) Which cost-effective high-speed medium should be used between buildings? (1 mark)
(v) The chain wants video consultations with doctors in Delhi. Suggest a suitable technology. (1 mark)
- Question 375 marks
Write a menu-driven program to implement a queue of customer names using a list: (1) add customer, (2) serve customer (remove from front, print 'Queue empty' if none), (3) display queue, (4) exit.
OR
Question 375 marksConsider tables STUDENT(RollNo, Name, ClassID) and CLASS(ClassID, ClassName, Teacher). Write SQL queries to:
(i) display student names with their class names, (ii) display the number of students in each class, (iii) display names of students taught by 'Mrs Sharma', (iv) display the class names that have more than 30 students, (v) add a column Phone to STUDENT.
Ready to attempt this paper?
Take it as a timed test of 180 minutes. Your answers are saved as you go and every answer is marked when you submit.
You'll be asked to log in or sign up first if needed.