Sample paper · Class 12 · CBSE · Science Computer Science
Computer Science · Sample Paper 2
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
The number of attributes (columns) in a relation is its
- A.cardinality
- B.degree
- C.tuple
- D.domain
- Question 21 mark
A set of allowed values for an attribute is its
- A.key
- B.domain
- C.tuple
- D.schema
- Question 31 mark
The time complexity of linear search in the worst case is
- A.O(1)
- B.O(log n)
- C.O(n)
- D.O(n²)
- Question 41 mark
Which keyword is used to raise an exception explicitly?
- A.throw
- B.raise
- C.except
- D.assert only
- Question 51 mark
Accessing an undefined variable raises
- A.TypeError
- B.NameError
- C.ValueError
- D.IndexError
- Question 61 mark
Which method reads the entire contents of a text file as a single string?
- A.readline()
- B.readlines()
- C.read()
- D.load()
- Question 71 mark
What does f.seek(0) do?
- A.closes the file
- B.moves the file pointer to the beginning
- C.returns file size
- D.deletes contents
- Question 81 mark
The operation that adds an element to a stack is
- A.enqueue
- B.push
- C.pop
- D.peek
- 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
A queue follows the principle
- A.LIFO
- B.FIFO
- C.FILO
- D.random
- Question 111 mark
Which sorting algorithm repeatedly selects the smallest element and places it at the beginning?
- A.bubble sort
- B.insertion sort
- C.selection sort
- D.merge sort
- Question 121 mark
Hashing allows searching in, ideally,
- A.O(n)
- B.O(log n)
- C.O(1)
- D.O(n²)
- Question 131 mark
Which SQL command is used to change data in existing rows?
- A.ALTER
- B.UPDATE
- C.INSERT
- D.MODIFY
- Question 141 mark
Which aggregate function returns the average of a column?
- A.SUM()
- B.AVG()
- C.MEAN()
- D.COUNT()
- Question 151 mark
SELECT * FROM emp WHERE salary BETWEEN 20000 AND 30000; includes salaries
- A.greater than 20000 and less than 30000 only
- B.from 20000 to 30000 inclusive
- C.below 20000
- D.above 30000
- Question 161 mark
A network spread over a city is a
- A.PAN
- B.LAN
- C.MAN
- D.WAN
- Question 171 mark
Which device amplifies and regenerates signals over long distances?
- A.router
- B.repeater
- C.switch
- D.modem
- Question 181 mark
The unit of data transfer rate is
- A.Hz
- B.bps
- C.byte
- D.dB
- Question 191 mark
A program that appears useful but secretly harms the computer is a
- A.worm
- B.trojan horse
- C.firewall
- D.cookie
- Question 201 mark
Assertion (A): Binary files are faster to read and write than text files.
Reason (R): Binary files store data in the same format as in memory, with no translation of characters.
- 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 primary key column can have NULL values.
Reason (R): A primary key uniquely identifies each row.
- 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 relation and a tuple with an example.
- Question 232 marks
Write the output:
try: L = [1, 2, 3] print(L[5]) except IndexError: print('Index problem') else: print('No error') finally: print('Done') OR
Question 232 marksDifferentiate between syntax errors and exceptions with an example of each.
- Question 242 marks
Write a function
count_the()that counts the occurrences of the word 'the' (any case) in a text filestory.txt. - Question 252 marks
Show the queue contents after each operation on an empty queue: enqueue(5), enqueue(8), dequeue(), enqueue(3), enqueue(7), dequeue().
- Question 262 marks
Differentiate between WHERE and HAVING clauses.
- Question 272 marks
Differentiate between circuit switching and packet switching.
- Question 282 marks
What is the difference between a virus and a worm?
Section C · Short answer
Questions 29–31 carry 3 marks each.
- Question 293 marks
Write a function to check whether the brackets in an expression string are balanced using a stack. E.g. '(a+[b*c])' is balanced, '(a+b]' is not.
OR
Question 293 marksShow the list after each pass of insertion sort on [9, 4, 7, 2].
- Question 303 marks
Write a program that reads a binary file
emp.datcontaining records [empno, name, salary] (pickled one by one) and displays those with salary above 50000. - Question 313 marks
What is data? Explain the steps of data processing and give one example of structured and unstructured data.
Section D · Long answer
Questions 32–35 carry 4 marks each.
- Question 324 marks
Consider the table BOOK:
| BookID | Title | Author | Price | Qty | |---|---|---|---|---| | B1 | Python Basics | Rao | 450 | 10 | | B2 | Data Science | Iyer | 600 | 5 | | B3 | SQL Made Easy | Rao | 350 | 8 | | B4 | Networks | Khan | 500 | 3 |
Write SQL queries to:
(i) display titles of books by 'Rao', (ii) display the total quantity of books, (iii) increase the price of all books by 10%, (iv) display author-wise number of books.
- Question 334 marks
Write a program to create a CSV file
marks.csvwith columns name and marks for n students entered by the user, then read it back and print the average marks. - Question 344 marks
Write a Python program using mysql.connector to insert a record (5, 'Neha', 88) into the table STUDENT(RollNo, Name, Marks) of database
schooland commit the change. OR
Question 344 marksExplain the advantages of a DBMS over a file system (any four).
- Question 354 marks
Explain (i) phishing (ii) spyware (iii) denial-of-service attack (iv) HTTPS, and how each relates to online security.
Section E · Long answer
Questions 36 and 37 carry 5 marks each.
- Question 365 marks
Case study — Hospital network. A hospital in Pune is setting up a network across four blocks: ADMIN, OPD, WARD and LAB. Distances: ADMIN–OPD 60 m, ADMIN–WARD 120 m, ADMIN–LAB 90 m, OPD–WARD 80 m, OPD–LAB 70 m, WARD–LAB 50 m. Computers: ADMIN 40, OPD 25, WARD 60, LAB 15. The hospital's head office is in Mumbai.
(i) Suggest the most suitable block to house the server, with a reason. (1 mark)
(ii) Suggest a cable layout (topology) to connect the blocks. (1 mark)
(iii) Where should repeaters be placed, if any? (1 mark)
(iv) Which device is needed in each block to connect its computers? (1 mark)
(v) Which type of network will connect the hospital with the Mumbai head office? (1 mark)
- Question 375 marks
Write a menu-driven program to implement a stack of book titles using a list with options to push, pop (print 'Underflow' if empty), peek, and display (top first).
OR
Question 375 marksConsider tables EMP(EmpID, Name, DeptID, Salary) and DEPT(DeptID, DName). Write SQL queries to:
(i) display each employee's name with the department name, (ii) display the department name and average salary for each department, (iii) display the highest salary in the 'Sales' department, (iv) delete employees whose salary is less than 15000, (v) add a column Phone of type VARCHAR(15) to EMP.
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.