Pre Borad QP Computer Science XII

Pre Borad QP Computer Science XII

Pre Board Examination
(2025–26)

Class XII – Computer Science (083)

Time: 3 Hours      Maximum Marks: 70

General Instructions

  1. This question paper contains four sections, Section A to E.
  2. All questions are compulsory.
  3. Section A has 22 questions (MCQs) carrying 1 mark each.
  4. Section B has 13 Very Short Answer type questions carrying 2 marks each.
  5. Section C has 3 Short Answer type questions carrying 3 marks each.
  6. Section D has 2 Long Answer type questions carrying 4 marks each.
  7. Section E has 1 Long Answer type question carrying 5 marks.
  8. All programming questions are to be answered using Python Language only.

SECTION – A (22 × 1 = 22 Marks)

Q1. State if the following statement is True or False:
Using the statistics module, the output of the below statements will be 20:

import statistics
statistics.median([10, 20, 10, 30, 10, 20, 30])

Q2. What will be the output of the following code?

L = ["Python", "Java", "Basic"] 
print(L[1][0] + L[2][-1])

a) JC  b) Pa  c) jc  d) Jc

Q3. Consider the given expression:

print(1919 or not 75 > 30)

a) True  b) False  c) Null  d) None of these

Q4. Which of the following is not a category of SQL statements?
a) DDL  b) FCL  c) DML  d) TCL

Q5. What will be the output of the following Python code?

str = "Computer Exam" 
print(str[-3::-3])

a) xruo  b) xrou  c) Eruo  d) xru

Q6. Write the output of the following code:

for k in range(7, 40, 6):
    print(k + '-')

a) TypeError  b) No output  c) Numbers from 7 to 39  d) None of these

Q7. Identify the DML command from the following:
a) UPDATE  b) ALTER  c) CREATE  d) DROP

Q8. Which of the following is an invalid variable/identifier in Python:
A) my_day_2  B) 2nd_day  C) Day_two  D) _2

Q9. There could be only one ________ key in MySQL database.
a) alternate  b) candidate  c) primary  d) all of these

Q10. Which block is used for exception handling in Python:
a) if–else  b) for–else  c) while  d) try–except

Q11. Find output of the following code:

data = {'apple': 10, 'banana': 20, 'orange': 30}
keys_list = list(data.keys())
print(keys_list[1])

a) 20  b) banana  c) 10  d) apple

Q12. What possible output is expected from the following code?

import random 
AR = [20,30,40,50,60,70]
FROM = random.randint(1,3)
TO = random.randint(2,4) 
for K in range(FROM, TO+1):
    print(AR[K], end="# ")

(i) 10#40#70#  (ii) 30#40#50#  (iii) 50#60#70#  (iv) 40#50#70#

Q13. What is the output of the following expression?

Sports = "Paralympic Games"
print(Sports.split("m"))

A) [‘Paraly’,’m’,’pic Ga’,’m’,’es’]  
B) (‘Paraly’,’m’,’pic Games’)  
C) (‘Paraly’,’pic Ga’,’es’)  
D) [‘Paraly’, ‘pic Ga’, ‘es’]

Q14. Which SQL command can change the cardinality of an existing relation?
a) Insert  b) Delete  c) Both (a) & (b)  d) Drop

Q15. In SQL, a relation consists of 5 columns and 6 rows. If 2 columns and 3 rows are added, what will be the updated degree?
a) Degree: 7  b) Degree: 8  c) Degree: 9  d) Degree: 6

Q16. Which operator tells whether an element is present in a sequence or not?
a) exist  b) in  c) into  d) inside

Q17. What will be the output of the following code segment?

p = list("Session 2024–25") 
print(p[10:20:])

Q18. Assertion (A): readlines() reads all the lines from a text file and returns them as a list of strings.
Reason (R): readline() can read the entire text file line by line without using loops.
A) Both A & R true and R explains A
B) Both A & R true but R doesn’t explain A
C) A true, R false
D) A false, R true

Q19. Which of the following statements is not true for parameter passing to functions?
a) You can pass positional arguments in any order.
b) You can pass keyword arguments in any order.
c) You can call a function with positional and keyword arguments.
d) Positional arguments must be before keyword arguments.

Q20. Assertion (A): Arguments matching number & order in function call are positional arguments.
Reason (R): During function call, default arguments come before positional arguments.
a) Both A & R true and R explains A
b) Both A & R true but R doesn’t explain A
c) A true, R false
d) A false, R true

Q21. The mode used for both writing and reading data from a binary file is:
a) wb+  b) w  c) wb  d) a

Q22. Consider the following code and choose the correct output:

n = '5'
try:
    print('WORD' + n, end="#")
except:
    print('ERROR', end="#")
finally:
    print('OVER')

a) WORD5#  b) WORD5#OVER  c) ERROR#OVER  d) ERROR#

SECTION – B (13 × 2 = 26 Marks)

Q23.
(a) Given:
NAME = "Learning Python is Fun"
Write the output of the following statement
print(NAME[-5:-10:-1])

(b) Write the output of the code given below :

dict1 = {1: ["Rohit", 20], 2: ["Siya", 90]}
dict2 = {1: ["Rahul", 95], 5: ["Rajan", 80]}
dict1.update(dict2)
print(dict1.values())

Q24. Explain the difference between explicit and implicit type conversion in Python with example.
OR
Write one example each for:
(i) Syntax error  (ii) Implicit type conversion

Q25. Differentiate between IN and BETWEEN operators in SQL with examples.

Q26. Explain the difference between break and continue statements in Python with example.

Q27. Correct the following code (underline corrections):

define remove_first_last(str):
    if len(str) < 2:
        return str
    new_str = str[1:-2]
    return new_str
result = remove_first_last("Hello")
Print("Resulting string:" result)

Q28.
Nisha is maintaining staff data in SQL table EMPLOYEES(EMPNO, NAME, DEPARTMENT, BASICSAL).

(i) (a) Identify attribute for PRIMARY KEY and justify.

OR

(b) Identify constraint so that NAME cannot be NULL but can have duplicates.

(ii) (a) Write SQL to display employees with salary < 80000.

OR

(b) Write SQL to delete table EMPLOYEES.

Q29. Differentiate between DROP and DELETE queries in SQL with examples.

Q30. Differentiate between text file and binary file.

OR

Differentiate between relative path and absolute path with examples.

Q31. Difference between 'a' and 'w' file modes.

OR

Difference between tell() and seek() functions.

Q32. Fill in the blanks:

import _______
fo = open("binary_file1.dat", "wb")
Laptop = ["Dell", "HP", "ACER"]
________.______(Laptop, fo)
fo.______

Q33. Explain the types of errors in Python.

Q34. What does the return statement do in a function? Explain with example.

Q35. Differentiate between break and continue statements in Python.

SECTION – C (3 × 3 = 9 Marks)

Q36. Write a Python function that displays all lines containing the word ‘vote’ from a text file Elections.txt.

OR

Write a Python function that displays all words starting and ending with a vowel from Report.txt.

Q37. Write Python functions to perform stack operations on ClrStack (push, pop, isEmpty).

OR

Write functions push_trail(), pop_one(), display_all() for list-based stack operations.

Q38. Predict the output of the following code:

def Examon(mystr):
    newstr = ""
    count = 0
    for i in mystr:
        if count % 2 != 0:
            newstr = newstr + str(count - 1)
        else:
            newstr = newstr + i.lower()
            count += 1
    newstr = newstr + mystr[:2]
    print("The new string is:", newstr)
Examon("GenX")

OR

def Change(X):
    for K, V in X.items():
        L1.append(K)
        L2.append(V)

D = {1: "ONE", 2: "TWO", 3: "THREE"}
L1 = []
L2 = []
Change(D)
print(L1)
print(L2)
print(D)

SECTION – D (2 × 4 = 8 Marks)

Suman has created a table named WORKER with a set of records to maintain the data of the construction sites, which consists of WID, WNAME, WAGE, HOURS, TYPE, and SITEID. After creating the table, she entered data in it, which is as follows:

WORKER

WIDWNAMEWAGEHOURSTYPESITEID
W01Ahmed J1500200Unskilled103
W11Naveen S520100Skilled101
W02Jacob B78095Unskilled101
W15Nihal K560110SemiskilledNULL
W10Anju S1200130Skilled103

Q39. (a) Based on WORKER table, write SQL queries:
(i) Display WNAME and WAGE of workers with wage between 800 and 1500.
(ii) Display record of workers whose SITEID is not known.
(iii) Display WNAME, WAGE, HOURS of workers where TYPE = ‘Skilled’.
(iv) Change WAGE to 1200 for TYPE = ‘Semiskilled’.

OR

(b) Write output for:
(i) SELECT WNAME, WAGE*HOURS FROM WORKER WHERE SITEID=103;
(ii) SELECT COUNT(DISTINCT TYPE) FROM WORKER;
(iii) SELECT MAX(WAGE), MIN(WAGE), TYPE FROM WORKER GROUP BY TYPE;
(iv) SELECT WNAME, SITEID FROM WORKER WHERE TYPE="Unskilled" ORDER BY HOURS;

Q40. A csv file “P_record.csv” contains the records of patients in a hospital. Each record of the file contains the following data :
Name of a patient , Disease, Number of days patient is admitted, Amount
For example, a sample record of the file may be :
[“Gunjan”, “Jaundice”, 4,15000]

Write the following Python functions to perform the specified operations on this file :
(i) Write a function read_data() which reads all the data from the file and displays the details of all the ‘Cancer’ patients.
(ii) Write a function count_rec() which counts and returns the number of records in the file.

SECTION – E (1 × 5 = 5 Marks)

Q41. A binary file PASSENGERS.DAT stores records as:
[PNR, PName, BRDSTN, DESTN, FARE]
Write Python functions:
(i) Create() – input passenger data and write to file.
(ii) SearchDestn(D) – display passengers whose DESTN = D.
(iii) UpdateFare() – increase fare by 5% and rewrite file.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top