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

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

    In a relational database, data is organised in

    1. A.trees
    2. B.tables (relations)
    3. C.graphs
    4. D.files only
  2. Question 21 mark

    All candidate keys other than the primary key are

    1. A.foreign keys
    2. B.alternate keys
    3. C.composite keys
    4. D.super keys
  3. Question 31 mark

    The best-case time complexity of linear search is

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

    Which keyword handles an exception in Python?

    1. A.catch
    2. B.except
    3. C.error
    4. D.handle
  5. Question 51 mark

    Which exception is raised for an invalid list index?

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

    Which method writes a list of strings to a text file?

    1. A.write()
    2. B.writelines()
    3. C.dump()
    4. D.append()
  7. Question 71 mark

    What does f.tell() return?

    1. A.file size
    2. B.current position of the file pointer
    3. C.number of lines
    4. D.file name
  8. Question 81 mark

    Which operation returns the top element without removing it?

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

    The postfix expression '3 4 + 2 *' evaluates to

    1. A.14
    2. B.11
    3. C.10
    4. D.24
  10. Question 101 mark

    A queue in which insertion and deletion can happen at both ends is a

    1. A.circular queue
    2. B.deque
    3. C.priority queue
    4. D.stack
  11. Question 111 mark

    Which sorting algorithm builds the final sorted list one item at a time by inserting into position?

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

    Linear search can be used on

    1. A.sorted lists only
    2. B.unsorted lists only
    3. C.both sorted and unsorted lists
    4. D.dictionaries only
  13. Question 131 mark

    Data that is collected for the first time by the user is

    1. A.secondary data
    2. B.primary data
    3. C.metadata
    4. D.derived data
  14. Question 141 mark

    Which command creates a new table?

    1. A.CREATE TABLE
    2. B.MAKE TABLE
    3. C.NEW TABLE
    4. D.INSERT TABLE
  15. Question 151 mark

    Which function counts non-NULL values in a column?

    1. A.COUNT(column)
    2. B.SUM(column)
    3. C.COUNT(*)
    4. D.MAX(column)
  16. Question 161 mark

    Which device connects multiple computers in a LAN and forwards data only to the intended device?

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

    The internet is an example of a

    1. A.LAN
    2. B.MAN
    3. C.WAN
    4. D.PAN
  18. Question 181 mark

    Which protocol is used to receive email?

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

    A program that blocks unauthorised access to a network is a

    1. A.virus
    2. B.firewall
    3. C.cookie
    4. D.browser
  20. Question 201 mark

    Assertion (A): A stack is used to check balanced parentheses.

    Reason (R): The last opened bracket must be closed first (LIFO).

    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): The HAVING clause is used with GROUP BY.

    Reason (R): HAVING applies conditions to groups.

    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 primary key and a foreign key.

  2. Question 232 marks

    Write the output:

    try:
        d = {'a': 1}
        print(d['b'])
    except KeyError:
        print('Missing key')
    else:
        print('Found')
    
  3. OR

    Question 232 marks

    What is the difference between raise and assert in Python?

  4. Question 242 marks

    Write a function count_vowels() that counts the vowels in a text file story.txt.

  5. Question 252 marks

    Evaluate the postfix expression 6 2 / 3 + 4 * using a stack, showing the stack after each operator.

  6. Question 262 marks

    Differentiate between COUNT(*) and COUNT(column_name).

  7. Question 272 marks

    Expand: (i) HTTP (ii) FTP (iii) IP (iv) Wi-Fi.

  8. Question 282 marks

    What is a cookie? Give one advantage and one risk.

Section C · Short answer

Questions 29–31 carry 3 marks each.

  1. Question 293 marks

    Write a Python function push_even(L, stack) that pushes all even numbers from list L onto a stack, and pop_all(stack) that pops and prints all elements.

  2. OR

    Question 293 marks

    Show the list after each pass of selection sort on [29, 10, 14, 37, 13].

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

  4. Question 313 marks

    Explain bandwidth, data transfer rate and IP address.

Section D · Long answer

Questions 32–35 carry 4 marks each.

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

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

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

  4. OR

    Question 344 marks

    Explain the terms relation, attribute, tuple, domain and degree with an example.

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

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

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

  3. OR

    Question 375 marks

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