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

Timed, marked on submit · free with an account

General instructions

  1. This paper has 37 questions in five sections, A to E. All questions are compulsory.
  2. Section A — Q1 to Q21: 1 mark each.
  3. Section B — Q22 to Q28: 2 marks each.
  4. Section C — Q29 to Q31: 3 marks each.
  5. Section D — Q32 to Q35: 4 marks each.
  6. Section E — Q36 and Q37: 5 marks each.
  7. Internal choice is given in Q23, Q29, Q34 and Q37. Answer only one alternative.
  8. All programming questions are to be answered in Python; queries in SQL (MySQL).

Section A · Objective

Questions 1–21 carry 1 mark each.

  1. Question 11 mark

    The number of attributes (columns) in a relation is its

    1. A.cardinality
    2. B.degree
    3. C.tuple
    4. D.domain
  2. Question 21 mark

    A set of allowed values for an attribute is its

    1. A.key
    2. B.domain
    3. C.tuple
    4. D.schema
  3. Question 31 mark

    The time complexity of linear search in the worst case is

    1. A.O(1)
    2. B.O(log n)
    3. C.O(n)
    4. D.O(n²)
  4. Question 41 mark

    Which keyword is used to raise an exception explicitly?

    1. A.throw
    2. B.raise
    3. C.except
    4. D.assert only
  5. Question 51 mark

    Accessing an undefined variable raises

    1. A.TypeError
    2. B.NameError
    3. C.ValueError
    4. D.IndexError
  6. Question 61 mark

    Which method reads the entire contents of a text file as a single string?

    1. A.readline()
    2. B.readlines()
    3. C.read()
    4. D.load()
  7. Question 71 mark

    What does f.seek(0) do?

    1. A.closes the file
    2. B.moves the file pointer to the beginning
    3. C.returns file size
    4. D.deletes contents
  8. Question 81 mark

    The operation that adds an element to a stack is

    1. A.enqueue
    2. B.push
    3. C.pop
    4. D.peek
  9. Question 91 mark

    The postfix form of (A + B) * C is

    1. A.A B C + *
    2. B.A B + C *
    3. C.
        • A B C
    4. D.A + B C *
  10. Question 101 mark

    A queue follows the principle

    1. A.LIFO
    2. B.FIFO
    3. C.FILO
    4. D.random
  11. Question 111 mark

    Which sorting algorithm repeatedly selects the smallest element and places it at the beginning?

    1. A.bubble sort
    2. B.insertion sort
    3. C.selection sort
    4. D.merge sort
  12. Question 121 mark

    Hashing allows searching in, ideally,

    1. A.O(n)
    2. B.O(log n)
    3. C.O(1)
    4. D.O(n²)
  13. Question 131 mark

    Which SQL command is used to change data in existing rows?

    1. A.ALTER
    2. B.UPDATE
    3. C.INSERT
    4. D.MODIFY
  14. Question 141 mark

    Which aggregate function returns the average of a column?

    1. A.SUM()
    2. B.AVG()
    3. C.MEAN()
    4. D.COUNT()
  15. Question 151 mark

    SELECT * FROM emp WHERE salary BETWEEN 20000 AND 30000; includes salaries

    1. A.greater than 20000 and less than 30000 only
    2. B.from 20000 to 30000 inclusive
    3. C.below 20000
    4. D.above 30000
  16. Question 161 mark

    A network spread over a city is a

    1. A.PAN
    2. B.LAN
    3. C.MAN
    4. D.WAN
  17. Question 171 mark

    Which device amplifies and regenerates signals over long distances?

    1. A.router
    2. B.repeater
    3. C.switch
    4. D.modem
  18. Question 181 mark

    The unit of data transfer rate is

    1. A.Hz
    2. B.bps
    3. C.byte
    4. D.dB
  19. Question 191 mark

    A program that appears useful but secretly harms the computer is a

    1. A.worm
    2. B.trojan horse
    3. C.firewall
    4. D.cookie
  20. 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.

    1. A.Both Assertion (A) and Reason (R) are true, and R is the correct explanation of A.
    2. B.Both Assertion (A) and Reason (R) are true, but R is not the correct explanation of A.
    3. C.Assertion (A) is true, but Reason (R) is false.
    4. D.Assertion (A) is false, but Reason (R) is true.
  21. Question 211 mark

    Assertion (A): A primary key column can have NULL values.

    Reason (R): A primary key uniquely identifies each row.

    1. A.Both Assertion (A) and Reason (R) are true, and R is the correct explanation of A.
    2. B.Both Assertion (A) and Reason (R) are true, but R is not the correct explanation of A.
    3. C.Assertion (A) is true, but Reason (R) is false.
    4. D.Assertion (A) is false, but Reason (R) is true.

Section B · Very short answer

Questions 22–28 carry 2 marks each.

  1. Question 222 marks

    Differentiate between a relation and a tuple with an example.

  2. 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')
    
  3. OR

    Question 232 marks

    Differentiate between syntax errors and exceptions with an example of each.

  4. Question 242 marks

    Write a function count_the() that counts the occurrences of the word 'the' (any case) in a text file story.txt.

  5. Question 252 marks

    Show the queue contents after each operation on an empty queue: enqueue(5), enqueue(8), dequeue(), enqueue(3), enqueue(7), dequeue().

  6. Question 262 marks

    Differentiate between WHERE and HAVING clauses.

  7. Question 272 marks

    Differentiate between circuit switching and packet switching.

  8. Question 282 marks

    What is the difference between a virus and a worm?

Section C · Short answer

Questions 29–31 carry 3 marks each.

  1. 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.

  2. OR

    Question 293 marks

    Show the list after each pass of insertion sort on [9, 4, 7, 2].

  3. Question 303 marks

    Write a program that reads a binary file emp.dat containing records [empno, name, salary] (pickled one by one) and displays those with salary above 50000.

  4. 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.

  1. 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.

  2. Question 334 marks

    Write a program to create a CSV file marks.csv with columns name and marks for n students entered by the user, then read it back and print the average marks.

  3. 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 school and commit the change.

  4. OR

    Question 344 marks

    Explain the advantages of a DBMS over a file system (any four).

  5. 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.

  1. 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)

  2. 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).

  3. OR

    Question 375 marks

    Consider 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.