Sample paper · Class 12 · CBSE · Science Computer Science
Computer Science · Sample Paper 1
CBSE board pattern (083), Class 12 syllabus — all 13 chapters. Programming language: Python; database: MySQL.
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 Q24, Q30, Q33 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
The number of rows in a relation is called its
- A.degree
- B.cardinality
- C.domain
- D.schema
- Question 21 mark
A key that refers to the primary key of another table is a
- A.candidate key
- B.foreign key
- C.alternate key
- D.composite key
- Question 31 mark
The time complexity of binary search is
- A.O(n)
- B.O(log n)
- C.O(n²)
- D.O(1)
- Question 41 mark
Which block always executes whether an exception occurs or not?
- A.try
- B.except
- C.else
- D.finally
- Question 51 mark
int('abc') raises
- A.TypeError
- B.ValueError
- C.NameError
- D.KeyError
- Question 61 mark
Which mode opens a file for appending?
- A.'r'
- B.'w'
- C.'a'
- D.'x'
- Question 71 mark
Which module is used to write Python objects to a binary file?
- A.csv
- B.pickle
- C.os
- D.json
- Question 81 mark
A stack follows the principle
- A.FIFO
- B.LIFO
- C.FILO only for queues
- D.random access
- Question 91 mark
The postfix form of A + B * C is
- A.A B + C *
- B.A B C * +
- C.
- A * B C
- D.A B C + *
- Question 101 mark
In a queue, deletion takes place at the
- A.rear
- B.front
- C.middle
- D.both ends
- Question 111 mark
In the worst case, bubble sort on n elements takes
- A.O(n)
- B.O(n log n)
- C.O(n²)
- D.O(log n)
- Question 121 mark
Binary search requires the list to be
- A.unsorted
- B.sorted
- C.of even length
- D.of strings
- Question 131 mark
Which SQL command removes a table along with its structure?
- A.DELETE
- B.DROP TABLE
- C.REMOVE
- D.TRUNCATE ROWS
- Question 141 mark
Which clause filters groups formed by GROUP BY?
- A.WHERE
- B.HAVING
- C.ORDER BY
- D.LIKE
- Question 151 mark
SELECT COUNT(*) FROM emp WHERE name LIKE 'A_%'; matches names that
- A.end with A
- B.start with A and have at least 2 characters
- C.have A as second letter
- D.are exactly 'A'
- Question 161 mark
Which device connects different networks and routes packets?
- A.hub
- B.switch
- C.router
- D.repeater
- Question 171 mark
Which topology has every node connected to a central device?
- A.bus
- B.ring
- C.star
- D.mesh
- Question 181 mark
Which protocol is used to send email?
- A.FTP
- B.SMTP
- C.HTTP
- D.PPP
- Question 191 mark
Malware that encrypts files and demands payment is
- A.worm
- B.trojan
- C.ransomware
- D.adware
- Question 201 mark
Assertion (A): Optical fibre is preferred for long-distance, high-speed communication.
Reason (R): Optical fibre carries data as light and is immune to electromagnetic interference.
- 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): A deque can be used as both a stack and a queue.
Reason (R): Insertion and deletion are allowed at both ends of a deque.
- 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 candidate key and a primary key with an example.
- Question 232 marks
Write the output:
try: x = 10 / 0 except ZeroDivisionError: print('Divide by zero') else: print('OK') finally: print('End') - Question 242 marks
Write a function
count_lines()that counts the lines in a text filenotes.txtthat start with 'T'. OR
Question 242 marksDifferentiate between text files and binary files (two points).
- Question 252 marks
Evaluate the postfix expression using a stack, showing the stack after each step: 5 3 + 2 *
- Question 262 marks
Differentiate between DDL and DML commands with one example each.
- Question 272 marks
Expand: (i) URL (ii) DNS (iii) MAC (iv) PAN.
- Question 282 marks
What is a firewall? Give two ways to protect a computer from malware.
Section C · Short answer
Questions 29–31 carry 3 marks each.
- Question 293 marks
Write functions
push(stack, item)andpop(stack)for a stack implemented as a list.popshould print 'Underflow' if the stack is empty. - Question 303 marks
Show the steps of binary search for 42 in [5, 11, 17, 23, 31, 42, 56].
OR
Question 303 marksShow the list after each pass of bubble sort on [7, 3, 9, 1].
- Question 313 marks
Write a program to append a student's [roll, name, marks] record to
student.datusing pickle, and a function to display all records.
Section D · Long answer
Questions 32–35 carry 4 marks each.
- Question 324 marks
Consider the table EMP:
| EmpNo | Name | Dept | Salary | |---|---|---|---| | 1 | Asha | HR | 40000 | | 2 | Ravi | IT | 60000 | | 3 | Meena | IT | 55000 | | 4 | Karan | Sales | 35000 | | 5 | Neha | HR | 45000 |
Write SQL queries to:
(i) display names of employees in IT;
(ii) display the average salary of each department;
(iii) increase the salary of HR employees by 10%;
(iv) display departments whose maximum salary is above 50000.
- Question 334 marks
Write a program to read
items.csv(columns: item, qty, price) and print the item with the highest total value (qty × price). OR
Question 334 marksWrite functions to implement a queue using a list:
enqueue,dequeue(print 'Empty' if needed) anddisplay.- Question 344 marks
Write Python code to connect to a MySQL database
schooland display all rows of the tablestudentwhose marks are above 80. - Question 354 marks
Explain four network devices with their functions.
Section E · Long answer
Questions 36 and 37 carry 5 marks each.
- Question 365 marks
Network design. A company has four blocks: Admin (40 computers), Finance (25), HR (15) and Store (10). Distances: Admin–Finance 60 m, Admin–HR 120 m, Admin–Store 50 m, Finance–HR 80 m, HR–Store 150 m.
(i) Suggest the most suitable block for the server, with a reason. (1 mark)
(ii) Suggest a cable layout connecting the blocks. (1 mark)
(iii) Where would you place a repeater? (1 mark)
(iv) Which device would you place in every block? (1 mark)
(v) Which type of network (PAN, LAN, MAN, WAN) is formed? (1 mark)
- Question 375 marks
Write a program that keeps asking for two integers and prints their quotient. Handle ValueError (non-integer input) and ZeroDivisionError with suitable messages; stop when the user enters 'q'.
OR
Question 375 marksExplain equi-join and natural join with an example using tables STUDENT(RollNo, Name, ClassID) and CLASS(ClassID, Teacher). Write a query to show each student's name with their teacher.
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.