Class 12 Computer Science Mock Tests, Chapter by Chapter

Loading educational resources and study material...

Wondering how well you know Computer Science? These Class 12 mock tests, made for CBSE 2026-27, give you an instant score after each attempt, so you always know where you stand.

Test Yourself on Every Computer Science Chapter (Class 12)

One test per Computer Science chapter, made for Class 12 and matched to the CBSE 2026-27 marking scheme. Click any chapter below to begin. No login needed, and you can retake tests freely.

Click Here to Start Class 12 Computer Science Online Practice Tests

Quick Practice - Class 12 Computer Science (Python & SQL Core)

Select any chapter below to test your programming logic, data structures, networking, and SQL database skills with 5 high-yield questions, instant scoring, and verified model explanations.

Q1.What is the output of the following Python code snippet?
t = (10, 20, 30, 40, 50)
print(t[1:4:2])

(a) (20, 30)
(b) (20, 40)
(c) (10, 30)
(d) (20, 30, 40)

Q2.Which of the following built-in data types in Python is strictly immutable?

(a) List
(b) Dictionary
(c) Tuple
(d) Set

Q3.What will be the result of evaluating the arithmetic expression: 16 // 3 + 4 ** 2 * 2?

(a) 37
(b) 35
(c) 42.33
(d) 69

Q4.What will be the output of the following dictionary operation?
d = {"A": 1, "B": 2}
print(d.get("C", 100))

(a) KeyError: 'C'
(b) None
(c) 0
(d) 100

Q5.What is the minimum and maximum possible number generated by random.randint(3, 8)?

(a) Min: 3, Max: 7
(b) Min: 3, Max: 8
(c) Min: 4, Max: 8
(d) Min: 0, Max: 8

Q1.What is the term used for default values assigned to function parameters in a Python function definition?

(a) Positional arguments
(b) Keyword arguments
(c) Default arguments
(d) Variable-length arguments

Q2.What keyword is used inside a function block to modify a variable declared outside in the top-level script scope?

(a) global
(b) nonlocal
(c) public
(d) outer

Q3.What will be the output of the following function code?
def change(L):
    L.append(100)
nums = [10, 20]
change(nums)
print(len(nums))

(a) 2
(b) 3
(c) 1
(d) Error: UnboundLocalError

Q4.In Python, what is the default return value of a function that completes execution without executing an explicit return statement?

(a) 0
(b) False
(c) Empty String ("")
(d) None

Q5.What order of namespaces does Python search when resolving an identifier (LEGB Rule)?

(a) Local → Enclosing → Global → Built-in
(b) Global → Local → Enclosing → Built-in
(c) Built-in → Global → Enclosing → Local
(d) Local → Global → Enclosing → Built-in

Q1.Which built-in Python module is used to read and write structured CSV (Comma Separated Values) files?

(a) pickle
(b) csv
(c) sys
(d) os

Q2.What is the purpose of the pickle.dump() function in binary file handling?

(a) To read an object from a binary file
(b) To delete a binary file from storage
(c) To serialize (write) a Python object structure into an open binary file stream
(d) To convert a binary file into a text file

Q3.What is the difference between the seek() and tell() methods in Python file handling?

(a) tell() returns the current byte position of the file pointer; seek() repositions the pointer
(b) seek() returns file length; tell() reads characters
(c) Both methods perform identical read operations
(d) tell() writes data; seek() closes the file stream

Q4.Which file opening mode opens a text file for appending data at the end without truncating existing content?

(a) 'r'
(b) 'w'
(c) 'w+'
(d) 'a'

Q5.What does the readlines() method return when executed on an open text file object?

(a) A single combined string containing the entire file
(b) A list of strings, where each element represents one line including the newline character
(c) A dictionary with line numbers as keys
(d) A tuple of binary byte values

Q1.What is the operational principle of a Stack data structure?

(a) LIFO (Last In, First Out) / FILO (First In, Last Out)
(b) FIFO (First In, First Out)
(c) Random Access Protocol
(d) Priority-based ordering

Q2.What condition occurs when a program attempts to pop an element from an empty stack?

(a) Overflow
(b) Segmentation fault
(c) Underflow
(d) Deadlock

Q3.When implementing a stack using a Python list stk = [], which pair of list methods represents the standard Push and Pop operations?

(a) stk.insert(0, item) and stk.remove(item)
(b) stk.append(item) and stk.pop()
(c) stk.extend(item) and stk.clear()
(d) stk.push(item) and stk.delete()

Q4.Given an initially empty stack, what will be the top element after executing the following sequence: Push(10), Push(20), Pop(), Push(30), Push(40), Pop(), Push(50)?

(a) 10
(b) 30
(c) 40
(d) 50

Q5.Which of the following is a direct real-world application of the Stack data structure in computing?

(a) Function call call-stack execution and 'Undo' operations in editors
(b) Print job spooling
(c) CPU round-robin scheduling
(d) Breadth-First Search in graphs

Q1.Which network device connects two different networks using different communication protocols and acts as a protocol converter?

(a) Hub
(b) Switch
(c) Gateway
(d) Repeater

Q2.What is the length of an IPv4 address and an IPv6 address respectively?

(a) 16 bits and 64 bits
(b) 32 bits and 128 bits
(c) 48 bits and 128 bits
(d) 64 bits and 256 bits

Q3.Which network topology connects every computer node to a central device (Hub/Switch), where a single cable failure does not affect the rest of the network?

(a) Star Topology
(b) Bus Topology
(c) Ring Topology
(d) Mesh Topology

Q4.Which Internet protocol is specifically responsible for securely fetching web pages using SSL/TLS encryption?

(a) FTP
(b) SMTP
(c) HTTP
(d) HTTPS (Port 443)

Q5.In network design, what rule is used to decide the placement of the server across multiple campus buildings?

(a) The building closest to the main entrance
(b) The building with the smallest area
(c) The 80-20 Rule / Building containing the maximum number of computers
(d) The building with the fewest rooms

Q1.In relational database theory, the number of tuples (rows) and the number of attributes (columns) in a table are called:

(a) Degree and Cardinality respectively
(b) Cardinality and Degree respectively
(c) Domain and Tuple
(d) Primary Key and Foreign Key

Q2.Which SQL aggregate function ignores NULL values while counting entries?

(a) COUNT(column_name)
(b) COUNT(*)
(c) SUM() including NULLs
(d) AVG(*)

Q3.What is the main functional difference between the WHERE clause and the HAVING clause in SQL queries?

(a) WHERE is used only with numeric data; HAVING is for text
(b) WHERE modifies table structure; HAVING retrieves data
(c) WHERE filters individual rows before grouping; HAVING filters grouped records after GROUP BY
(d) Both are completely interchangeable

Q4.Which category of SQL commands do CREATE, ALTER, and DROP belong to?

(a) DDL (Data Definition Language)
(b) DML (Data Manipulation Language)
(c) DCL (Data Control Language)
(d) TCL (Transaction Control Language)

Q5.What is the Cartesian product (Degree and Cardinality) of Table A (Degree = 3, Cardinality = 4) and Table B (Degree = 2, Cardinality = 5)?

(a) Degree = 6, Cardinality = 9
(b) Degree = 5, Cardinality = 9
(c) Degree = 6, Cardinality = 20
(d) Degree = 5, Cardinality = 20

Q1.Which Python connector package is commonly used to establish database connectivity between Python and a MySQL database?

(a) mysql.database
(b) mysql.connector
(c) python.sql
(d) py.dbms

Q2.What is the role of a cursor object in Python-MySQL database programming?

(a) It acts as a control structure to execute SQL queries and fetch rows from the result set
(b) It stores database server passwords
(c) It creates graphics on the computer screen
(d) It formats SQL backup files

Q3.Which cursor method retrieves all remaining rows of an executed SQL query as a list of tuples in Python?

(a) cursor.fetchmany()
(b) cursor.readall()
(c) cursor.fetchall()
(d) cursor.fetchone()

Q4.Why must the connection.commit() method be called after executing an INSERT, UPDATE, or DELETE statement in Python?

(a) To close the network socket connection
(b) To clear query cache memory
(c) To create a primary key index
(d) To permanently save and commit pending transaction changes to the database tables

Q5.What value does the cursor.rowcount property return after executing a SQL statement?

(a) Total count of tables inside the database
(b) The number of rows affected by a DML query or returned by a SELECT query
(c) Total column count of the target table
(d) Execution time in milliseconds

FAQs

How do I access the 2026-27 Class 12 Computer Science Online Mock Tests?

You can start the latest Computer Science mock tests for Class 12 by selecting your chapter from the links above. These tests are free, dont need login and are optimized for the 2026-27 academic session.

Are the Class 12 online tests based on the new CBSE MCQ pattern?

Yes, our Computer Science online tests are strictly as per the latest CBSE pattern with 20% MCQ weightage and main focus on competency-based and case-study questions.

Can I see my score and answers instantly after the Computer Science test?

After submitting your Class 12 Computer Science test, you can see score report and correct/incorrect answers.

Is there a limit to how many times I can attempt these Class 12 mock tests?

There are no limits. You can re-attempt any Computer Science online test as many times for free, master concepts, improve your speed and accuracy.

Do these Class 12 Computer Science tests work on smartphones?

Yes, the StudiesToday online test platform is mobile-first. Class 12 Computer Science students can take these tests on any smartphone.

How do online mock tests help in Class 12 Computer Science exam preparation?

Online tests help Class 12 students build confidence and time management. By solving above tests MCQs you can apply theoretical knowledge which is important for 2026-27 exams.