Sample paper · Class 12 · CBSE · Science Computer Science

Computer Science · Sample Paper 3

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

    Software used to create and manage databases is a

    1. A.DBMS
    2. B.compiler
    3. C.browser
    4. D.spreadsheet
  2. Question 21 mark

    A key that can uniquely identify rows but is not chosen as the primary key is an

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

    Which of these has the worst-case time complexity O(n²)?

    1. A.binary search
    2. B.linear search
    3. C.bubble sort
    4. D.accessing a list element
  4. Question 41 mark

    Which exception is raised when dividing by zero?

    1. A.ValueError
    2. B.ZeroDivisionError
    3. C.TypeError
    4. D.IndexError
  5. Question 51 mark

    The else block in try–except runs when

    1. A.an exception occurs
    2. B.no exception occurs
    3. C.always
    4. D.never
  6. Question 61 mark

    Which mode opens a file for reading and writing without truncating it?

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

    Which function writes a Python object to a binary file?

    1. A.pickle.load()
    2. B.pickle.dump()
    3. C.write()
    4. D.csv.writer()
  8. Question 81 mark

    Removing the top element of a stack is called

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

    The infix form of the postfix expression '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

    Inserting an element into a queue is called

    1. A.push
    2. B.enqueue
    3. C.dequeue
    4. D.pop
  11. Question 111 mark

    After the first pass of bubble sort (ascending) on [5, 1, 4, 2], the list is

    1. A.[1, 4, 2, 5]
    2. B.[1, 5, 4, 2]
    3. C.[1, 2, 4, 5]
    4. D.[5, 4, 2, 1]
  12. Question 121 mark

    The maximum number of comparisons in binary search on 16 sorted elements is about

    1. A.4–5
    2. B.8
    3. C.16
    4. D.2
  13. Question 131 mark

    Data that can be stored in rows and columns is called

    1. A.unstructured data
    2. B.structured data
    3. C.metadata
    4. D.big data only
  14. Question 141 mark

    Which constraint ensures a column cannot have NULL values?

    1. A.UNIQUE
    2. B.NOT NULL
    3. C.DEFAULT
    4. D.CHECK
  15. Question 151 mark

    SELECT DISTINCT city FROM customer; returns

    1. A.all cities with repeats
    2. B.each city only once
    3. C.the number of cities
    4. D.an error
  16. Question 161 mark

    Which device connects a computer to the internet over telephone lines by modulating signals?

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

    A network of computers within a building is a

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

    Which protocol is used to transfer web pages?

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

    Unauthorised access to a computer system is

    1. A.hacking
    2. B.browsing
    3. C.backup
    4. D.encryption
  20. Question 201 mark

    Assertion (A): Insertion sort is efficient for nearly sorted lists.

    Reason (R): In a nearly sorted list, few elements need to be shifted.

    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 switch is more efficient than a hub.

    Reason (R): A switch sends data only to the intended device, while a hub broadcasts to all.

    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

    What is meant by the degree and cardinality of a relation? Give an example.

  2. Question 232 marks

    Write the output:

    try:
        x = int('12a')
    except ValueError:
        print('Invalid')
    finally:
        print('End')
    
  3. OR

    Question 232 marks

    What is the purpose of the finally block? Give one situation where it is useful.

  4. Question 242 marks

    Write a function display_long() that displays the lines of poem.txt that have more than 30 characters.

  5. Question 252 marks

    Convert the infix expression (A + B) * (C − D) to postfix, showing the stack steps briefly.

  6. Question 262 marks

    Differentiate between CHAR and VARCHAR data types in SQL.

  7. Question 272 marks

    Expand: (i) TCP/IP (ii) VoIP (iii) HTML (iv) LAN.

  8. Question 282 marks

    What is two-factor authentication? Give an example.

Section C · Short answer

Questions 29–31 carry 3 marks each.

  1. Question 293 marks

    Write functions enqueue(q, item) and dequeue(q) for a queue implemented as a list; dequeue should print 'Underflow' if the queue is empty.

  2. OR

    Question 293 marks

    Show the steps of binary search for 23 in [4, 8, 15, 16, 23, 42, 50].

  3. Question 303 marks

    Write a program to read students.csv (columns: roll, name, marks) and print the names of students who scored above 90.

  4. Question 313 marks

    Distinguish between guided and unguided transmission media with two examples of each.

Section D · Long answer

Questions 32–35 carry 4 marks each.

  1. Question 324 marks

    Consider the table STUDENT:

    | RollNo | Name | Class | Marks | City | |---|---|---|---|---| | 1 | Asha | 12 | 88 | Delhi | | 2 | Ravi | 11 | 72 | Pune | | 3 | Meena | 12 | 95 | Delhi | | 4 | Arjun | 12 | 65 | Mumbai |

    Write SQL queries to:

    (i) display the names of students from Delhi, (ii) display the average marks of class 12 students, (iii) display the details of students whose name starts with 'A', (iv) display the number of students in each city.

  2. Question 334 marks

    Write a program that copies only those lines from source.txt to target.txt which do not start with the character '#'.

  3. Question 344 marks

    Write a Python program using mysql.connector to display all records from the table EMP of database office where salary is greater than 50000.

  4. OR

    Question 344 marks

    Differentiate between DELETE and DROP commands, and between ALTER and UPDATE commands, with examples.

  5. Question 354 marks

    Explain the star, bus, ring and tree topologies with one advantage of each.

Section E · Long answer

Questions 36 and 37 carry 5 marks each.

  1. Question 365 marks

    Case study — School campus network. A school in Jaipur has four blocks: ADMIN, SCIENCE, JUNIOR and SPORTS. Distances: ADMIN–SCIENCE 80 m, ADMIN–JUNIOR 150 m, ADMIN–SPORTS 120 m, SCIENCE–JUNIOR 60 m, SCIENCE–SPORTS 90 m, JUNIOR–SPORTS 70 m. Computers: ADMIN 30, SCIENCE 80, JUNIOR 40, SPORTS 10.

    (i) Suggest the best block for the server, with a reason. (1 mark)

    (ii) Suggest a cable layout to connect the blocks. (1 mark)

    (iii) Which device should be used to connect computers within each block? (1 mark)

    (iv) The school wants to connect to its branch in another city. What type of network is this? (1 mark)

    (v) Suggest a cost-effective way to provide internet in the SPORTS block, which is far from others. (1 mark)

  2. Question 375 marks

    Write a program that uses a stack to reverse a string entered by the user, and then checks whether the string is a palindrome.

  3. OR

    Question 375 marks

    Write a menu-driven program to (1) add a record [itemno, name, price] to the binary file items.dat, (2) display all records, (3) search for an item by item number.

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.