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

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 Q24, Q30, Q33 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 rows in a relation is called its

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

    A key that refers to the primary key of another table is a

    1. A.candidate key
    2. B.foreign key
    3. C.alternate key
    4. D.composite key
  3. Question 31 mark

    The time complexity of binary search is

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

    Which block always executes whether an exception occurs or not?

    1. A.try
    2. B.except
    3. C.else
    4. D.finally
  5. Question 51 mark

    int('abc') raises

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

    Which mode opens a file for appending?

    1. A.'r'
    2. B.'w'
    3. C.'a'
    4. D.'x'
  7. Question 71 mark

    Which module is used to write Python objects to a binary file?

    1. A.csv
    2. B.pickle
    3. C.os
    4. D.json
  8. Question 81 mark

    A stack follows the principle

    1. A.FIFO
    2. B.LIFO
    3. C.FILO only for queues
    4. D.random access
  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

    In a queue, deletion takes place at the

    1. A.rear
    2. B.front
    3. C.middle
    4. D.both ends
  11. Question 111 mark

    In the worst case, bubble sort on n elements takes

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

    Binary search requires the list to be

    1. A.unsorted
    2. B.sorted
    3. C.of even length
    4. D.of strings
  13. Question 131 mark

    Which SQL command removes a table along with its structure?

    1. A.DELETE
    2. B.DROP TABLE
    3. C.REMOVE
    4. D.TRUNCATE ROWS
  14. Question 141 mark

    Which clause filters groups formed by GROUP BY?

    1. A.WHERE
    2. B.HAVING
    3. C.ORDER BY
    4. D.LIKE
  15. Question 151 mark

    SELECT COUNT(*) FROM emp WHERE name LIKE 'A_%'; matches names that

    1. A.end with A
    2. B.start with A and have at least 2 characters
    3. C.have A as second letter
    4. D.are exactly 'A'
  16. Question 161 mark

    Which device connects different networks and routes packets?

    1. A.hub
    2. B.switch
    3. C.router
    4. D.repeater
  17. Question 171 mark

    Which topology has every node connected to a central device?

    1. A.bus
    2. B.ring
    3. C.star
    4. D.mesh
  18. Question 181 mark

    Which protocol is used to send email?

    1. A.FTP
    2. B.SMTP
    3. C.HTTP
    4. D.PPP
  19. Question 191 mark

    Malware that encrypts files and demands payment is

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

    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 deque can be used as both a stack and a queue.

    Reason (R): Insertion and deletion are allowed at both ends of a deque.

    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 candidate key and a primary key with an example.

  2. Question 232 marks

    Write the output:

    try:
        x = 10 / 0
    except ZeroDivisionError:
        print('Divide by zero')
    else:
        print('OK')
    finally:
        print('End')
    
  3. Question 242 marks

    Write a function count_lines() that counts the lines in a text file notes.txt that start with 'T'.

  4. OR

    Question 242 marks

    Differentiate between text files and binary files (two points).

  5. Question 252 marks

    Evaluate the postfix expression using a stack, showing the stack after each step: 5 3 + 2 *

  6. Question 262 marks

    Differentiate between DDL and DML commands with one example each.

  7. Question 272 marks

    Expand: (i) URL (ii) DNS (iii) MAC (iv) PAN.

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

  1. Question 293 marks

    Write functions push(stack, item) and pop(stack) for a stack implemented as a list. pop should print 'Underflow' if the stack is empty.

  2. Question 303 marks

    Show the steps of binary search for 42 in [5, 11, 17, 23, 31, 42, 56].

  3. OR

    Question 303 marks

    Show the list after each pass of bubble sort on [7, 3, 9, 1].

  4. Question 313 marks

    Write a program to append a student's [roll, name, marks] record to student.dat using pickle, and a function to display all records.

Section D · Long answer

Questions 32–35 carry 4 marks each.

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

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

  3. OR

    Question 334 marks

    Write functions to implement a queue using a list: enqueue, dequeue (print 'Empty' if needed) and display.

  4. Question 344 marks

    Write Python code to connect to a MySQL database school and display all rows of the table student whose marks are above 80.

  5. Question 354 marks

    Explain four network devices with their functions.

Section E · Long answer

Questions 36 and 37 carry 5 marks each.

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

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

  3. OR

    Question 375 marks

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