I will provide you with Important PYQs Computer Science Class 12 in this article. So let us start discussing Important PYQs Computer Science Class 12.
Topics Covered
Why to practice Important PYQs Computer Science Class 12?
Important PYQs Computer Science Class 12 are very crucial to ace your computer science class 12 theory exams. Here are few reasons:
Practicing Important PYQs (Previous Year Questions) for Computer Science Class 12 is highly beneficial for several reasons:
Exam Pattern Familiarity
PYQs help you understand the types of questions that are frequently asked.
They give insights into the marking scheme and weightage of different topics.
Concept Clarity
By solving past questions, you reinforce key concepts and improve problem-solving skills.
It helps identify strong and weak areas in your syllabus.
Time Management
Regular practice improves your speed and accuracy during exams.
You learn how to allocate time for different sections effectively.
Boosts Confidence
Solving PYQs reduces exam anxiety as you get familiar with question patterns.
It increases your confidence in tackling different types of questions.
Identifies Important Topics
Certain topics are repeatedly asked in exams, indicating their importance.
Practicing PYQs helps you focus more on high-weightage topics.
Improves Answer Writing Skills
You learn how to structure answers efficiently to maximize marks.
Practicing coding questions enhances programming skills and logic-building.
Reduces Surprise Element
Since many questions are repeated in board exams, solving PYQs increases the chances of encountering familiar questions.
So let start with Important PYQs Computer Science Class 12. Here we go!
1 mark questions
As per the CBSE Sample Paper and Previous Year’s question papers, 1-mark questions are an important element of board exams. Let us start with 1-mark questions which include fill-in-the-blank, MCQs, True/False, one-word answers, and all sorts of very short answer types questions. Here we go!
[1] State True or False : “In Python, tuple is a mutable data type”.
A Primary Key is chosen from the set of Candidate Keys in a table.
Candidate Keys are those that uniquely identify each row and do not contain redundant attributes.
Out of multiple Candidate Keys, one is selected as the Primary Key, while the rest become Alternate
Keys.
Other options:
(A) Composite Key: A key made up of multiple columns.
(B) Alternate Key: Candidate keys that are not chosen as the primary key.
(D) Foreign Key: A key that refers to the primary key of another table.
[3] What will be the output of the following statement?
Explanation:
Operator Precedence in Python:
1. Exponentiation (**) has the highest precedence.
2. Division (/) and Floor Division (//) are evaluated next (left to right).
3. Addition (+) comes last.
Step-by-Step Evaluation:
Exponentiation (**): 4**2 = 16
So, the expression simplifies to:
6 + 5 / 16 // 5 + 8
Division (/):5/16 = 0.3125
The expression now becomes:
6 + 0.3125 // 5 + 8
Floor Division (//):0.3125//5=0.0
(Since // gives the floor value of the division result)
Now, we have:
6 + 0.0 + 8
Explanation:
Understanding strip(): The strip(chars) method removes all occurrences of the characters in chars from both the beginning and the end of the string. It does not remove characters from the middle of the string.
Step-by-Step Execution:
Given String: “text#next”
Characters to Remove: The strip(“t”) function will remove all leading and trailing occurrences of the letter ‘t’ from the string.
Processing:
– The first ‘t’ at the start is removed → “ext#next”
– The last ‘t’ at the end is removed → “ext#nex”
Hence the aswer is : ext#nex
[5] In SQL, which command will be used to add a new record in a table? (A) UPDATE (B) ADD (C) INSERT (D) ALTER TABLE
Explanation:The INSERT command in SQL is used to add a new record (row) to a table.
Other options:
(A) UPDATE → Used to modify existing records, not add new ones.
(B) ADD → Not a valid SQL command for inserting records.
(D) ALTER TABLE → Used to modify the structure of a table (e.g., adding/removing columns), not inserting records.
Explanation:
HTML stands for HyperText Markup Language, where:
H → Hyper
T → Text
M → Markup
L → Language
It is the standard language used for creating web pages and web applications.
Other options are related to HTML.
[7] Identify the valid Python identifier from the following: (A) 2user
Explanation:
A valid Python identifier follows these rules:
✅ Can contain letters (a-z, A-Z), digits (0-9), and underscores (_).
✅ Cannot start with a digit.
✅ Cannot contain special characters like @, #, $, etc.
✅ Cannot have spaces.
✅ Cannot be a Python keyword.
Other Options:
(A) 2user ❌ Invalid → Cannot start with a digit.
(B) user@2 ❌ Invalid → Contains @, which is not allowed.
(D) user 2 ❌ Invalid → Contains a space, which is not allowed.
[8] Consider the statements given below and then choose the correct output from the given options:
Explanation:
The mode() function returns the most frequently occurring value in the given list.
The list provided is: [10, 20, 10, 30, 10, 20, 30]
Count of each element:
10 appears 3 times
20 appears 2 times
30 appears 2 times
The most frequent number is 10.
[10] Which of the following output will never be obtained when the given code is executed?
Explanation:
– random.randrange(10) generates a random integer from 0 to 9.
– Adding 1 shifts the range to 1 to 10.
– Possible values for Shuffle: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
– random.randrange(5) generates a random integer from 0 to 4.
– Multiplying by 10 results in values {0, 10, 20, 30, 40}.
– Possible values for Draw: {0, 10, 20, 30, 40}
(A) Shuffle 1 # Draw 0
Shuffle = 1 ✅ (Valid, since range is 1-10)
Draw = 0 ✅ (Valid, since possible values are {0, 10, 20, 30, 40})
✅ Possible Output
(B) Shuffle 10 # Draw 10
Shuffle = 10 ✅ (Valid, since range is 1-10)
Draw = 10 ✅ (Valid, since 10 is a valid value)
✅ Possible Output
(C) Shuffle 10 # Draw 0
Shuffle = 10 ✅ (Valid, since range is 1-10)
Draw = 0 ✅ (Valid, since 0 is a valid value)
✅ Possible Output
(D) Shuffle 11 # Draw 50
Shuffle = 11 ❌ (Invalid, since Shuffle can only be between 1 and 10)
Draw = 50 ❌ (Invalid, since Draw can only be {0, 10, 20, 30, 40})
❌ Impossible Output
Explanation:
An Ethernet card is commonly referred to as a NIC (Network Interface Card). It is a hardware component that allows a computer to connect to a network using wired (Ethernet) or wireless (Wi-Fi) communication.
Other Options:
(A) LIC & (D) OIC are No such common terms in networking.
(B) MIC → Could stand for Microphone or other terms, but not related to networking.
Explanation:
Let’s analyze the given Python code step by step:
a = 10
def convert(b=20):
a = 30 # This is a local variable inside the function
c = a + b
print(a, c) # Prints the local values of ‘a’ and ‘c’
convert(30)
print(a) # Prints the global ‘a’
Step-by-Step Execution:
1. Global variable initialization:
a = 10
– The variable `a` is defined **globally** with the value `10`.
2. Function Definition:
def convert(b=20):
– The function `convert()` is defined with a default parameter `b=20`.
3. Calling `convert(30)`:
convert(30)
– `b` takes the value `30` (because we passed `30` as an argument).
– Inside the function:
a = 30
– A new local variable `a` is created inside the function, which is separate from the global `a`.
c = a + b # c = 30 + 30 = 60
– `c` is calculated as `30 + 30 = 60`.
print(a, c) # Prints: 30 60
– Prints “30 60” inside the function.
4. Printing `a` outside the function:
print(a)
– The global `a` remains unchanged (`a = 10`), because the `a = 30` inside the function was local to `convert()`.
– So, it prints “10”.
Final Output:
30 60
10
[13] For the following Python statement : N = (25) What shall be the type of N? (A) Integer (B) String (C) Tuple (D) List
Explanation:
In Python, parentheses alone do not make a tuple unless there is a comma inside.
Here, N is simply assigned the value 25, which is an integer.
Other Options:
(B) String → Strings are enclosed in quotes (’25’ or “25”), which is not the case here.
(C) Tuple → A single-element tuple must have a comma, like this: N(25,)
(D) List → Lists are enclosed in square brackets ([]), like: N = [25]
[14] Mr. Ravi is creating a field that contains alphanumeric values and fixed lengths. Which MySQL data type should he choose for the same? (A) VARCHAR (B) CHAR (C) LONG (D) NUMBER
Explanation:
– CHAR is used when the length of the value is fixed, meaning it will always occupy the same number of characters. If the string is shorter than the fixed length, it will be padded with spaces.
– VARCHAR is used for variable-length strings, so it would not be suitable for fixed-length values.
– LONG and NUMBER are not valid MySQL data types for storing alphanumeric strings.
[15] Fill in the blank : The full form of WWW is _______________________.
Explanation:
Binary files are stored as a sequence of raw bytes. Unlike text files, which use a specific encoding to represent characters, binary files can store any kind of data, such as images, audio files, video files, compiled software, etc.
Binary files don’t follow a human-readable format, and the bytes are interpreted according to the structure or format the file represents. For example, a .jpg image or a .exe executable file is a binary file.
This is the correct answer because the question asks about files stored in a sequence of bytes without specifying whether it’s for human-readable data (which is typically text).
Other Options:
(A) Text
Text files store human-readable characters, such as letters, numbers, and punctuation. These characters are encoded in a specific format, like ASCII or UTF-8, where each character corresponds to a byte or a series of bytes.
While text files are stored as bytes, they are different from binary files because they follow a more structured, human-readable format. Examples include .txt files or .csv files when they contain text data.
(C) CSV
CSV (Comma-Separated Values) is a type of text file that uses a specific format to store data in rows and columns, often used for spreadsheets or databases.
CSV files are typically text files and are stored as sequences of characters. Even though they can contain alphanumeric data, CSV files still follow a text format and aren’t considered binary files. They are human-readable text, often used in applications like Excel or databases.
While they contain structured data (like numbers and strings), CSV files are still ultimately text files, not binary files.
(D) Notepad
Notepad refers to a text editor, not a file type. When you create a file in Notepad, it saves the content as a text file (usually .txt), which contains human-readable characters stored in a specific encoding.
The content of a Notepad file is still represented in text format (usually as ASCII or UTF-8 encoded characters), so it’s not a binary file.
[17] Assertion (A) : Global variables are accessible in the whole program. Reason (R) : Local variables are accessible only within a function or block in which it is declared.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A). (B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A). (C) Assertion (A) is true, but Reason (R) is false. (D) Assertion (A) is false, but Reason (R) is true.
Ans.: (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
Explanation:
A global variable is declared outside of any function or block and can be accessed from anywhere in the program, including inside functions or other code blocks.
A local variable is declared inside a function or block, and its scope is limited to that function or block. It cannot be accessed outside of the function or block where it is defined.
[18] Assertion (A) : If numeric data are to be written to a text file, the data needs to be converted into a string before writing to the file. Reason (R) : write() method takes a string as an argument and writes it to the text file. (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A). (B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A). (C) Assertion (A) is true, but Reason (R) is false. (D) Assertion (A) is false, but Reason (R) is true.
Ans.: (A)Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
Explanation:
In Python, the write() method of a file object only accepts strings as arguments.
If you want to write numeric data (integers, floats, etc.) to a text file, you must convert it to a string using str().
Since the reason correctly explains why the assertion is true, option (A) is the best choice.
[19] State True or False: While defining a function in Python, the positional parameters in the function header must always be written after the default parameters.
Explanation:
This results in a SyntaxError, because a non-default (positional) parameter cannot follow a default parameter. In Python, positional parameters must always be written before default parameters in a function header.
[20] The SELECT statement when combined with ___________ the clause, returns records without repetition.
Explanation:
The SELECT statement in SQL, when combined with the DISTINCT clause, removes duplicate records from the result set.
Other Options:
(b) DESCRIBE → Used to get the structure of a table, not for filtering duplicates.
(c) UNIQUE → Used in table constraints, not in SELECT queries.
(d) NULL → Represents missing values in SQL, not used for removing duplicates.
[22] What will be the output of the following statement: print(16*5/4*2/5-8)
Explanation:
Step-by-step calculation:
Multiplication and Division (Left to Right, as they have the same precedence):
16 × 5 = 80
80 ÷ 4 = 20.0
20.0 × 2 = 40.0
40.0 ÷ 5 = 8.0
Subtraction:
8.0 − 8 = 0.0
[23] What possible output from the given options is expected to be displayed when the following Python code is executed?
import random
Signal=['RED','YELLOW','GREEN']
for K in range(2,0,-1):
R = random.randrange(K)
print(Signal[R], end='#')
random.randrange(2) generates either 0 or 1 (not 2 because randrange(K) returns values in the range [0, K-1]).
If R = 0, Signal[R] = ‘RED’.
If R = 1, Signal[R] = ‘YELLOW’.
Loop Iteration 2 (K = 1):
random.randrange(1) only returns 0.
So, Signal[R] = ‘RED’.
Possible Outputs:
Since the first value can be either ‘RED’ or ‘YELLOW’, and the second value is always ‘RED’, the only valid output from the options is: YELLOW # RED #
[24] In SQL, the aggregate function which will display the cardinality of the table is:
Explanation:
Cardinality in SQL refers to the number of rows in a table.
The COUNT(*) function returns the total number of rows in a table, which represents its cardinality.
Other options:
(a) SUM() → Used to sum values in a numeric column, not to count rows.
(c) AVG() → Calculates the average of numeric values, not row count.
(d) SUM(*) → Invalid function; SUM() requires a numeric column, but * does not refer to a numeric field.
[25] Which protocol out of the following is used to send and receive emails over a computer network?
Explanation:
SMTP (Simple Mail Transfer Protocol) is the standard protocol used for sending emails over a computer network. It is responsible for transmitting emails from an email client to an email server and between email servers.
Other Options:
(a) PPP (Point-to-Point Protocol) → Used for establishing a direct connection between two network nodes, not for emails.
(b) HTTP (Hypertext Transfer Protocol) → Used for accessing web pages, not for email transmission.
(c) FTP (File Transfer Protocol) → Used for transferring files between computers, not for sending or receiving emails.
[26] Identify the invalid Python statement from the following :