English

Computer Science (Python) Set 4 2025-2026 Commerce (English Medium) Class 12 Question Paper Solution

Advertisements
Computer Science (Python) [Set 4]
Marks: 50 CBSE
Commerce (English Medium)
Science (English Medium)
Arts (English Medium)

Academic Year: 2025-2026
Date & Time: 25th March 2026, 10:30 am
Duration: 3h
Advertisements

General Instructions:

  1. This question paper contains 37 questions.
  2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt only one of the choices in such questions.
  3. The paper is divided into 5 SectionsA, B, C, D and E.
  4. Section A consists of 21 questions (1 to 21). Each question carries 1 mark.
  5. Section B consists of 7 questions (22 to 28). Each question carries 2 marks.
  6. Section C consists of 3 questions (29 to 31). Each question carries 3 marks.
  7. Section D consists of 4 questions (32 to 35). Each question carries 4 marks.
  8. Section E consists of 2 questions (36 & 37). Each question carries 5 marks.
  9. All programming questions are to be answered using Python Language only.
  10. In case of MCQs, text of the correct answer should also be written.

SECTION - A
[1]1.

State True or False:

In Python, data type of 74 is same as the data type of 74.0.

Concept: undefined - undefined
Chapter:
[1]2.

Identify the output of the following code snippet:

8 = “the Truth”

print(s.capitalize())

The truth

THE TRUTH

The Truth

the Truth

Concept: undefined - undefined
Chapter:
[1]3.

Which of the following expressions in Python evaluates to True?

2>3 and 2<3

3>1 and 2

3>1 and 3>2

3>1 and 3<2

Concept: undefined - undefined
Chapter:
[1]4.

What is the output of the following code snippet?

s=‘War and Peace by Leo Tolstoy’

print(s.partition(“by”))

('War and Peace ', 'by', ' Leo Tolstoy')

['War and Peace ', 'by', ' Leo Tolstoy']

('War and Peace ', ' Leo Tolstoy')

['War and Peace ', ' Leo Tolstoy']

Concept: undefined - undefined
Chapter:
[1]5.

What will be the output of the following statement?

print(“PythonProgram”[−1:2:−2])

Concept: undefined - undefined
Chapter:
[1]6.

What will be the output of the following code snippet?

t = tuple('tuple')

t2 = t[2],

t += t2

print(t)

(‘tuple’)

(‘tuple’,‘p’)

(‘t’, ‘u’, ‘p’, ‘1’, ‘e’, ‘p’)

(‘t’, ‘u’, ‘p’, ‘1’, ‘e’)

Concept: undefined - undefined
Chapter:
[1]7.

Which of the following statements is true about dictionaries in Python?

A dictionary is an example of sequence data type.

A dictionary cannot have two elements with same key.

A dictionary cannot have two elements with same value.

The key and value of an element cannot be the same.

Concept: undefined - undefined
Chapter:
[1]8.

If L is a list with 6 elements, then which of the following statements will raise an exception?

L.pop (1)

L.pop (6)

L.insert(1,6)

L.insert(6,1)

Concept: undefined - undefined
Chapter:
[1]9.

What will be the output of the following code?

def f1(a,b=1):

     print(a+b,end='-')

c=f1(1,2)

print(c,sep='*')

3−2

3−2*

3−None

3*None

Concept: undefined - undefined
Chapter:
[1]10.

Consider the statement given below:

f1 = open(“pqr.dat”,“______”)

Which of the following is the correct file mode to open the file in read only mode?

a

rb

r+

rb+

Concept: undefined - undefined
Chapter:
[1]11.

State whether the following statement is True or False:

In Python, Logical errors can be handled using try...except...finally statement.

Concept: undefined - undefined
Chapter:
[1]12.

A table has two candidate keys, one of which is chosen as the primary key. How many alternate keys does this table have?

0

1

2

3

Concept: undefined - undefined
Chapter:
[1]13.

Which of the following SQL command can change the degree of the existing relation?

DROP TABLE

ALTER TABLE

UPDATE...SET

DELETE

Concept: undefined - undefined
Chapter:
[1]14.

What will be the output of the query?

SELECT MACHINE ID, MACHINE NAME FROM INVENTORY WHERE QUANTITY <= 100;

All columns of INVENTORY table with quantity greater than 100.

ID and name of machines with quantity less than 100 from INVENTORY table.

All columns of INVENTORY table with quantity greater than or equal to 100.

ID and name of machines with quantity less than or equal to 100 from INVENTORY table.

Concept: undefined - undefined
Chapter:
[1]15.

A relation in MySQL database consists of 2 tuples and 3 attributes. If 2 attributes are deleted and 4 tuples are added, what will be the cardinality of the relation?

4

5

6

7

Concept: undefined - undefined
Chapter:
[1]16.

Which aggregate function in SQL returns the smallest value from a column in a table?

MIN()

MAX()

SMALL()

LOWER()

Concept: undefined - undefined
Chapter:
Advertisements
[1]17.

With respect to computer networks, which of the following is the correct expanded form of RJ 45?

Radio Jockey 45

Registered Jockey 45

Radio Jack 45

Registered Jack 45

Concept: undefined - undefined
Chapter:
[1]18.

Which network device serves as the entry and exit point of a network, a all data coming in or going out of a network must first pass through it in order to use routing paths?

Modem

Gateway

Switch

Repeater

Concept: undefined - undefined
Chapter:
[1]19.

Expand the following term:

XML

Concept: undefined - undefined
Chapter:
Q. Nos. 20 and 21 are Assertion (A) and Reason (R) based questions. Mark the correct choice as:
[1]20.

Assertion (A): [1,2,3]+‘123’ is an invalid expression in Python.

Reason (R): In Python, a list cannot be concatenated with a string.

Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).

Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A).

Assertion (A) is true, but Reason (R) is false.

Assertion (A) is false, but Reason (R) is true.

Concept: undefined - undefined
Chapter:
[1]21.

Assertion (A): The PRIMARY KEY constraint in SQL ensures that each value in the column(s) is unique and cannot be NULL.

Reason (R): Candidate keys are not eligible to become a primary key.

Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).

Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A).

Assertion (A) is true, but Reason (R) is false.

Assertion (A) is false, but Reason (R) is true.

Concept: undefined - undefined
Chapter:
SECTION - B
[1]22. (a)

What is the difference between default Parameters and positional parameters in Python? 

Concept: undefined - undefined
Chapter:
[1]22. (b)

Give an example of a function header which uses both.

Concept: undefined - undefined
Chapter:
[1]23. (i)

Write a Python statement to perform the following tasks: (USE BUILT-IN FUNCTIONS/METHODS ONLY)

To create a new list L1 containing the elements of list L arranged in ascending order, without modifying list L.

Concept: undefined - undefined
Chapter:
[1]23. (ii)

Write a Python statement to perform the following tasks: (USE BUILT-IN FUNCTIONS/METHODS ONLY)

A statement to check whether the given character, ch is an alphabet or a number.

Concept: undefined - undefined
Chapter:
[1]24. (i) (a)

Assuming that D1 is a dictionary in Python.

Write a Python expression to check if the key, ‘RNo’ is present in D1.

Concept: undefined - undefined
Chapter:
OR
[1]24. (i) (b)

Assuming that D1 is a dictionary in Python.

Write a Python expression to check if any key in D1 has a value 12.

Concept: undefined - undefined
Chapter:
[1]24. (ii) (a)

Assuming that D1 is a dictionary in Python.

Write a single statement using a BUILT_IN function to add the key:

value pair ‘RNo’: 12, if the key ‘RNo’ is not present in D1. However, if the key ‘RNo’ is present, the function should return its value.

Concept: undefined - undefined
Chapter:
OR
[1]24. (ii) (b)

Assuming that D1 is a dictionary in Python.

Write a single statement to delete all the elements from D1.

Concept: undefined - undefined
Chapter:
[2]25.

What possible output(s) from the given options will NOT be displayed when the following code is executed? Also, mention, for how many iterations the for loop in the given code will run?

import random
a = [1, 2, 3, 4, 5, 6]
for i in range (4) :
    j = random.randrange (i, 5)
    print(a[j],end='-')
print()

3−4−5−4−

2−2−4−5−

4−3−3−5−

5−1−2−4−

Concept: undefined - undefined
Chapter:
[2]26.

The function given below is written to accept a string s as a parameter and return the number of vowels appearing in the string. The code has certain errors. Observe the code carefully and rewrite it after removing all the logical and syntax errors. Underline all the corrections made.

def CountVowels(s):
    c=0
    for ch in range(s):
        if 'aeiouAEIOU' in ch:
            c=+1
    return(ch)
Concept: undefined - undefined
Chapter:
[2]27.

Ms. Zoya is a Production Manager in a factory which packages mineral water. She decides to create a table in a database to keep track of the stock present in the factory. Each record of the table will have the following fields:

W_Code – Code of the item (type – CHAR (5))

W_Description – Description of the item (type – VARCHAR (20))

B_Qty – Balance quantity of the item (type – INTEGER)

U_Price – Unit Price of the item (type – FLOAT)

The name of the table is W_STOCK.

  1. Write an SQL command to create the above table (W_Code should be the primary key).
    OR
  2. Can U Price be the primary key of the above table? Justify your answer.
  3. Assuming that the table w_STOCK is already created, write an SQL command to add an attribute E_Date (of DATE type) to the table.
    OR
  4. Assuming that the table W_STOCK is already created, write an SQL command to remove the column B_Qty from the table.
Concept: undefined - undefined
Chapter:
Advertisements
[1]28. (a) (i)

List one advantage of the bus topology.

Concept: undefined - undefined
Chapter:
[1]28. (a) (ii)

List one disadvantage of the bus topology.

Concept: undefined - undefined
Chapter:
OR
[1]28. (b) (i)

What is protocol in the context of computer networks?

Concept: undefined - undefined
Chapter:
[1]28. (b) (ii)

Which protocol is used to transmit hypertext across the web?

Concept: undefined - undefined
Chapter:
SECTION - C
[3]29. (a)

Write a Python function that counts and returns the number of digits appearing in the text file “Space.txt”. For example, if the file contains:

Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity's cosmic journey continues!

Then the function should return 11.

Concept: undefined - undefined
Chapter:
OR
[3]29. (b)

Write a Python function that displays the words in which the lowercase letter ‘e’ appears at least twice in the text file ‘Space.txt’. For example, if the file contains:

Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity’s cosmic journey continues!

Then the function should display:
incredible advancements science agencies serves research.

Concept: undefined - undefined
Chapter:
[3]30. (a)

A stack named FruitStack, implemented using list, contains records of some fruits. Each record is represented as a dictionary with keys 'Name''Origin''Price', and 'Expiry'. A sample record is given here:
{'Name' : 'Apple', 'Origin' : 'France', 'Price' : 120, 'Expiry' : '12-08-2025'}

Write the following user-defined functions in Python to perform the specified operations on FruitStack:

  1. push_fruit(FruitStack, Fruit): This function takes the stack FruitStack and a new record Fruit as arguments and pushes the record stored in Fruit onto FruitStack if the Price is less than 100.
  2. pop_fruit(FruitStack): This function pops the topmost record from the stack and returns it. If the stack is already empty, the function should display "UNDERFLOW".
  3. display(FruitStack): This function displays all the elements of the stack starting from the topmost element. If the stack is empty, the function should display 'EMPTY STACK'.
Concept: undefined - undefined
Chapter:
OR
[3]30. (b)

Write a Python program to accept 10 integers from the user. If the entered number is a three-digit even integer, push it onto a stack. After all inputs are taken, pop all the three-digit even integers from the stack and display them. For example, if the user enters 12, 31, 320, 457, 6, 92, 924, 220, 1, 218, then the stack should contain:

320, 924, 220, 218

and the output of the program should be:

218 220 924 320

Concept: undefined - undefined
Chapter:
[3]31. (a)
Write the output of the following code:
def Exam2026(given) :
    new=[]
    for ch in given[1:-1]:
        if ch.isupper() :
            new.reverse()
        elif ch not in new:
            new.append(ch)
        elif ch in new:
            new.pop()
    print(new)
Exam2026("Gold-24Medals")
Concept: undefined - undefined
Chapter:
OR
[3]31. (b)

Write def the output of the following code:

def Exam2026(given) :
    new = 0
    while given:
        if new % 2:
            new += given % 10
        else:
            new += given % 5
        print(new, end='-')
        given //= 10
Exam2026(123456)
Concept: undefined - undefined
Chapter:
SECTION -D
[4]32. (a)

Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his shop. After creating the table, he entered the data and the table looked as follows:

Code Type Volume Qty Price
AF0.5 F 0.5 300 38.00
MFO.5 F 0.5 250 36.50
MT1.О T 1.0 150 64.00
AT1.0 T 1.0 100 66.00
PD1.0 D 1.0 50 52.00
PT0.5 T 0.5 78 30.00

Based on the data given above, write the SQL queries for the following tasks:

  1. To display Type and the maximum Price for each Type of milk.
  2. For each record, increase the Price by 0.5 where Type is 'F'.
  3. To display the total value of the stock (total of Qty x Price).
  4. To display the details of all records where Code starts with 'A'.
Concept: undefined - undefined
Chapter:
OR
[4]32. (b)

Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his shop. After creating the table, he entered the data and the table looked as follows:

Code Type Volume Qty Price
AF0.5 F 0.5 300 38.00
MFO.5 F 0.5 250 36.50
MT1.О T 1.0 150 64.00
AT1.0 T 1.0 100 66.00
PD1.0 D 1.0 50 52.00
PT0.5 T 0.5 78 30.00
Considering the table STOCK as given above, write the output on execution of the following queries :
  1. SELECT Volume, Qty, Price FROM STOCK
            WHERE Type IN ('F', 'D');
  2. SELECT Code, Qty FROM STOCK
            WHERE Price BETWEEN 30 AND 50;
  3. SELECT DISTINCT Type FROM STOCK;
  4. SELECT Volume, count(*) FROM STOCK GROUP BY Volume;
Concept: undefined - undefined
Chapter:
[4]33.
A csv file “States.csv” contains some data about all the states of India. Each record of the file contains the following data:
  • Name of the State
  • Capital of the State
  • Population of the State
  • Official Language of the State
For example, a sample record in the file is:
['Andhra Pradesh', 'Amaravati', 52221000, 'Telugu']
Write a Python program which reads the data from this file and appends all those records where population is more than 10000000 into another csv file 'More.csv'.
Note : "States.csv" also contains the Header row. The Header row should NOT be copied to "More.csv".
Concept: undefined - undefined
Chapter:
[4]34.

Assume that you are the Manager of the Loans department of a Finance House. To keep track of the loans you have created two tables : CUSTOMERS and LOANS. The sample data in these tables is given below:

Table: CUSTOMERS
C_ID C_Name Phone
00001 Raj Malhotra 1234567890
00003 David Xavier 3456789012
00004 Damini Iyer 3156789012
00008 Abdul 2345678901
Table: LOANS
SNO CID L Amt L Date Terms RoI
1 00003 200000 2025-12-06 60 7.80
2 00008 2500000 2023-08-09 60 9.00
3 00001 500000 2025-08-13 48 6.00
4 00003 300000 2026-12-07 36 8.00
5 00004 600000 2026-12-07 60 6.00

Note: The tables may contain more records than shown here.

The management of the Finance House needs certain reports from you. Write the queries to extract the following data to create the reports:
  1. Number of records from LOANS table where Rate of Interest (RoI) is above 7.0.
  2. Names of the customers whose loan amount (L_Amt) is above 1000000.
  3. C_ID, C_Name and Terms of all those records where Loan Date (L_Date) is after 31st December, 2024.
  4. (a)
    1. Details of all the loans in the descending order of RoI.
      OR
    2. C_ID and average term for each C_ID from the LOANS table.
Concept: undefined - undefined
Chapter:
[4]35.

Peter has created a table named Account in MySQL database, SCHOOL, having following structure:

  • Stud id - integer
  • Sname - string
  • Class - string
  • Fees - float

Help him in writing a Python program to display records of those students whose fees is less than 5000.

Note the following to establish connectivity between Python and MySQL:

  • Username - admin
  • Password - root
  • Host - localhost
Concept: undefined - undefined
Chapter:
SECTION - E
[5]36.
NextStep is an organization which has a pool of resource persons to conduct training workshops on various topics related to ICT. The data of all its Resource Persons is stored in a binary file RESOURCES.DAT using the following record structure (each record is a tuple):
        (R_ID, R_Name, R_Expertise, Charges)
where:
R_ID – Resource Person’s ID (An integer)
R_Name – Resource Person’s Name (A string)
R_Expertise – Area of expertise of the Resource Person
Charges – Charges (in rupees) per hour to conduct a workshop

 For example, a record in the file is:
(12, ‘P. Velusami’, ‘Machine Learning’, 5000)

In this context, write the following user defined functions in Python:
  1. Append() – To input the data of a Resource Person and write it in the file RESOURCES.DAT.
  2. Update() – To increase the Charges of each resource person by 500.
Concept: undefined - undefined
Chapter:
[5]37.

Sanjeevani is a big group of educational institutions with its head office in Hyderabad. It is planning to set up a new University in Amritsar. The Amritsar University Campus will have four blocks/buildings − ADMIN, ACADEMIC, HOSTEL, SPORTS. You, as a network expert, need to suggest the best network-related solutions for them to resolve the issues/problems mentioned in points (i) to (v), keeping in mind the distances between various blocks / buildings and other given parameters.

Amritsar University Campus

Block to Block distances (in Mtrs.)

FROM TO DISTANCE
ADMIN ACADEMIC 60 M
ADMIN HOSTEL 160 M
ADMIN SPORTS 80 M
ACADEMIC HOSTEL 40 M
ACADEMIC SPORTS 120 M
HOSTEL SPORTS 150 M

Distance of Hyderabad Head Office from Amritsar University Campus = 2000 km.

Number of computers in each block is as follows:

ADMIN 25
ACADEMIC 600
HOSTEL 120
SPORTS 50
  1. Suggest the most appropriate location of the server inside the Amritsar University Campus. Justify your choice.
  2. Draw the cable layout to efficiently connect various blocks within the Amritsar University Campus.
  3. Name any two wired media that can be used to connect various computers of a block inside Amritsar Campus.
  4. For the academic purpose, the University will provide its own 24 x 7 FM channel within the University Campus. Which communication medium, out of the following, is used by FM?
    1. Radio Waves
    2. Micro Waves
    3. Infrared Waves

    1. The students will be attending a lot of online academic sessions and workshops. These will involve audio-visual communication. Write the full name of the protocol which will be used for such a communication through the internet.
      OR
    2. Where should a repeater be installed in Amritsar University campus to boost the signal between blocks? Justify your answer.
Concept: undefined - undefined
Chapter:

Other Solutions



































Video TutorialsVIEW ALL [2]

Submit Question Paper

Help us maintain new question papers on Shaalaa.com, so we can continue to help students




only jpg, png and pdf files

CBSE previous year question papers Class 12 Computer Science (Python) with solutions 2025 - 2026

     CBSE Class 12 Computer Science (Python) question paper solution is key to score more marks in final exams. Students who have used our past year paper solution have significantly improved in speed and boosted their confidence to solve any question in the examination. Our CBSE Class 12 Computer Science (Python) question paper 2026 serve as a catalyst to prepare for your Computer Science (Python) board examination.
     Previous year Question paper for CBSE Class 12 Computer Science (Python)-2026 is solved by experts. Solved question papers gives you the chance to check yourself after your mock test.
     By referring the question paper Solutions for Computer Science (Python), you can scale your preparation level and work on your weak areas. It will also help the candidates in developing the time-management skills. Practice makes perfect, and there is no better way to practice than to attempt previous year question paper solutions of CBSE Class 12.

How CBSE Class 12 Question Paper solutions Help Students ?
• Question paper solutions for Computer Science (Python) will helps students to prepare for exam.
• Question paper with answer will boost students confidence in exam time and also give you an idea About the important questions and topics to be prepared for the board exam.
• For finding solution of question papers no need to refer so multiple sources like textbook or guides.
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×