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.
|
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? Answer: (b) (20, 40). Slicing syntax is
[start:stop:step]. Here, extraction starts at index 1 (value 20), stops before index 4 (values at indices 1, 2, 3), and steps by 2, picking index 1 (20) and index 3 (40).Q2.Which of the following built-in data types in Python is strictly immutable? Answer: (c) Tuple. Tuples, integers, floats, strings, and frozensets are immutable; their in-memory values cannot be modified in place once created. Lists, dictionaries, and sets are mutable.
Q3.What will be the result of evaluating the arithmetic expression: Answer: (a) 37. Following operator precedence: Exponentiation first (
4 ** 2 = 16), then multiplication & floor division left-to-right (16 // 3 = 5, and 16 * 2 = 32), then addition: 5 + 32 = 37.Q4.What will be the output of the following dictionary operation? Answer: (d) 100. The
dict.get(key, default) method returns the value of the key if present; otherwise, it safely returns the specified default value without raising a KeyError.Q5.What is the minimum and maximum possible number generated by Answer: (b) Min: 3, Max: 8. The
randint(a, b) function from the random module returns a random integer $N$ such that $a \le N \le b$, including both endpoints.Q1.What is the term used for default values assigned to function parameters in a Python function definition? Answer: (c) Default arguments. Default arguments provide fallback values if no corresponding argument is passed during the function call. In Python syntax, non-default arguments must precede default arguments.
Q2.What keyword is used inside a function block to modify a variable declared outside in the top-level script scope? Answer: (a) global. The
global statement declares that a particular variable belongs to the global scope, permitting assignment and modification inside a local function block.Q3.What will be the output of the following function code? Answer: (b) 3. Python uses "pass by object reference." Because lists are mutable, in-place modifications performed on the parameter
L reflect directly on the original nums list.Q4.In Python, what is the default return value of a function that completes execution without executing an explicit Answer: (d) None. A void function or any function reaching the end of its body without returning a value implicitly returns Python's special singleton object
None.Q5.What order of namespaces does Python search when resolving an identifier (LEGB Rule)? Answer: (a) Local → Enclosing → Global → Built-in. The LEGB rule defines Python's scope resolution sequence starting with inner Local scope up to the Built-in namespace.
Q1.Which built-in Python module is used to read and write structured CSV (Comma Separated Values) files? Answer: (b) csv. Python's standard
csv module provides reader(), writer(), writerow(), and writerows() for handling tabular CSV data.Q2.What is the purpose of the Answer: (c) To serialize (write) a Python object structure into an open binary file stream.
pickle.dump(object, file_handle) performs serialization (pickling), while pickle.load(file_handle) performs de-serialization (unpickling).Q3.What is the difference between the Answer: (a)
tell() returns the current byte position; seek() repositions the pointer. file.tell() gives the exact cursor location, while file.seek(offset, reference_point) moves the pointer to a target byte offset.Q4.Which file opening mode opens a text file for appending data at the end without truncating existing content? Answer: (d) 'a'. Mode
'a' opens the file for writing and places the file pointer at the end of the file. If the file does not exist, it creates a new one. Mode 'w' overwrites existing contents.Q5.What does the Answer: (b) A list of strings, where each element represents one line.
file.read() returns a single string, file.readline() reads one line at a time, and file.readlines() reads all remaining lines into a list.Q1.What is the operational principle of a Stack data structure? Answer: (a) LIFO (Last In, First Out). A stack allows insertions (Push) and deletions (Pop) to occur exclusively at one end, known as the 'Top' of the stack.
Q2.What condition occurs when a program attempts to pop an element from an empty stack? Answer: (c) Underflow. 'Underflow' is the exception condition when a deletion (pop) is attempted on an empty stack (i.e., when
len(stack) == 0 or Top == -1). 'Overflow' occurs when trying to push into a full stack.Q3.When implementing a stack using a Python list Answer: (b)
stk.append(item) and stk.pop(). In list-based stack implementations, append() adds an element to the top of the stack (end of the list), and pop() removes and returns the topmost element.Q4.Given an initially empty stack, what will be the top element after executing the following sequence: Answer: (d) 50. Step-by-step: [10] → [10, 20] → Pop 20 [10] → [10, 30] → [10, 30, 40] → Pop 40 [10, 30] → [10, 30, 50]. The topmost element is 50.
Q5.Which of the following is a direct real-world application of the Stack data structure in computing? Answer: (a) Function call call-stack execution and 'Undo' operations in editors. Stacks manage nested function calls, recursive backtracking, expression evaluation (infix/postfix), and undo/redo histories. Print queues use FIFO Queue structures.
Q1.Which network device connects two different networks using different communication protocols and acts as a protocol converter? Answer: (c) Gateway. A gateway connects dissimilar networks that utilize different architecture and protocol stacks. A router forwards packets across similar IP networks.
Q2.What is the length of an IPv4 address and an IPv6 address respectively? Answer: (b) 32 bits and 128 bits. IPv4 addresses are 32-bit values written in dotted-decimal notation (e.g., 192.168.1.1), while IPv6 uses 128-bit values written in hexadecimal blocks.
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? Answer: (a) Star Topology. In a Star topology, each workstation has a dedicated point-to-point connection to the central hub or switch. If one node cable breaks, only that node is disconnected.
Q4.Which Internet protocol is specifically responsible for securely fetching web pages using SSL/TLS encryption? Answer: (d) HTTPS (Port 443). HyperText Transfer Protocol Secure (HTTPS) encrypts communication over computer networks, preventing eavesdropping and tampering.
Q5.In network design, what rule is used to decide the placement of the server across multiple campus buildings? Answer: (c) Building containing the maximum number of computers. Placing the central server in the building with the highest concentration of client machines minimizes overall inter-building network traffic and reduces long-distance transmission latency.
Q1.In relational database theory, the number of tuples (rows) and the number of attributes (columns) in a table are called: Answer: (b) Cardinality and Degree respectively. Cardinality is the total count of records (rows), whereas Degree is the total count of fields (columns).
Q2.Which SQL aggregate function ignores NULL values while counting entries? Answer: (a)
COUNT(column_name). COUNT(column_name) counts only non-NULL entries in that specific column. COUNT(*) counts all rows, including records containing NULL values.Q3.What is the main functional difference between the Answer: (c)
WHERE filters individual rows; HAVING filters grouped records. WHERE cannot be used with aggregate functions (e.g., HAVING AVG(Marks) > 80), which require the HAVING clause.Q4.Which category of SQL commands do Answer: (a) DDL (Data Definition Language). DDL commands define, alter, and delete database structures and schemas. Commands like
INSERT, UPDATE, and DELETE belong to DML.Q5.What is the Cartesian product (Degree and Cardinality) of Table A (Degree = 3, Cardinality = 4) and Table B (Degree = 2, Cardinality = 5)? Answer: (d) Degree = 5, Cardinality = 20. In a Cartesian Product (Cross Join): Resultant Degree = $3 + 2 = 5$ (columns add), and Resultant Cardinality = $4 \times 5 = 20$ (rows multiply).
Q1.Which Python connector package is commonly used to establish database connectivity between Python and a MySQL database? Answer: (b)
mysql.connector. import mysql.connector enables Python programs to open connections, execute SQL statements, and retrieve result sets from MySQL databases.Q2.What is the role of a Answer: (a) It acts as a control structure to execute SQL queries and fetch rows. A cursor object (created via
connection.cursor()) provides methods like execute(), fetchone(), and fetchall().Q3.Which cursor method retrieves all remaining rows of an executed SQL query as a list of tuples in Python? Answer: (c)
cursor.fetchall(). fetchall() returns all query result rows as a list of tuples. fetchone() returns a single tuple or None if no more rows are available.Q4.Why must the Answer: (d) To permanently save and commit pending transaction changes. DML modifications are held in temporary memory until committed. Without
commit(), changes are rolled back when the connection closes.Q5.What value does the Answer: (b) The number of rows affected by a DML query or returned by a SELECT query.
cursor.rowcount is an integer property indicating the number of records fetched, updated, deleted, or inserted. |
| Computer Hardware Mock Test Set 01 |
| Computer Hardware Mock Test Set 02 |
| Computer Hardware Mock Test Set 03 |
| Computer Hardware Mock Test Set 04 |
| Computer network Mock Test Set 01 |
| Computer network Mock Test Set 02 |
| Computer network Mock Test Set 03 |
| Computer network Mock Test Set 04 |
| Data Structure Mock Test Set 01 |
| Data Structure Mock Test Set 02 |
| Data Structures Mock Test Set 01 |
| Data Structures Mock Test Set 02 |
| Database Concepts Mock Test Set 01 |
| Database Concepts Mock Test Set 02 |
| Database Concepts Mock Test Set 03 |
| Database Management System Mock Test Set 01 |
| Database Management System Mock Test Set 02 |
| For Loop in Python Mock Test Set 01 |
| For Loop in Python Mock Test Set 02 |
| Fundamentals of Computer Mock Test Set 01 |
| Fundamentals of Computer Mock Test Set 02 |
| Fundamentals of Computer Mock Test Set 03 |
| Fundamentals of Computer Mock Test Set 04 |
| Interface Python with SQL Mock Test Set 01 |
| Interface Python with SQL Mock Test Set 02 |
| MS Excel Mock Test Set 01 |
| MS Excel Mock Test Set 02 |
| MS Excel Mock Test Set 03 |
| MS Excel Mock Test Set 04 |
Free study material for Computer Science
FAQs
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.
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.
After submitting your Class 12 Computer Science test, you can see score report and correct/incorrect answers.
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.
Yes, the StudiesToday online test platform is mobile-first. Class 12 Computer Science students can take these tests on any smartphone.
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.
