PRE-BOARD EXAMINATION 2023-24
Class: XII Session: 2023-24
Computer Science (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
Please check this question paper contains 35 questions.
The paper is divided into 4 Sections- A, B, C, D and E.
Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
Que Question Marks
s No
SECTION A
1 1. Name the Python Library modules which need to be imported to invoke the following functions: 1
(i) floor()
(ii) randn()
2 Which of the following can be used as valid variable identifier(s) in Python? 1
My.file, _count, For, 2digits, 4thSu, Total, Number#, Name1
3 What will be the output of the following statement: 1
print(3-2**2**3+99/11)
a. 244 b. 244.0
c. -244.0 d. Error
4 Select the correct output of the code: 1
a=1;
def f ( ):
a=10
print (a)
5 1
What is namespace in Python?
6 Riya wants to transfer pictures from her mobile phone to her laptop. She 1
uses Bluetooth Technology to connect two devices. Which type of network
will be formed in this case?
a. PAN b. LAN
c. MAN d. WAN
7 Which of the following will delete key-value pair for key = “Red” from a 1
dictionary D1?
a. delete D1("Red")
b. del D1["Red"]
c. del.D1["Red"]
d. D1.del["Red"]
8 Consider the statements given below and then choose the correct output 1
from the given options:
pride="#G20 Presidency"
print(pride[-2:2:-2])
Options:
a. ndsr
b. ceieP0
c. ceieP
d. yndsr
9 def main(): 1
r = input('enter any radius :')
a = pi * math.pow(r,2)
print("Area = " + a)
10 What possible outputs(s) will be obtained when the following code is 1
executed?
def CALLME(n1=1, n2=2):
n1=n1*n2
n2+=2
print(n1, n2)
CALLME()
CALLME(2,1)
CALLME(3)
11 Fill in the blank: 1
The modem at the sender’s computer end acts as a .
a. Model
b. Modulator
c. Demodulator
d. Convertor
12 Consider the code given below: 1
Which of the following statements should be given in the blank for
#Missing Statement, if the output produced is 110?
Options:
a. global a
b. global b=100
c. global b
d. global a=100
13 What are the possible outcomes executed from the following code? Also, specify the maximum and 1
minimum values that can be assigned to variable COUNT.
import random
TEXT = "CBSEONLINE"
COUNT = random.randint(0,3)
C=9
while TEXT[C] != 'L':
print(TEXT[C]
+TEXT[COUNT]
+'*',end=" ") COUNT=
COUNT + 1
C = C
(i) EC* NB* IS*
(ii) NS* IE* LO*
(iii) ES* NE* IO*
(iv) LE* NO* ON*
14 Which of the following statements is FALSE about keys in a relational 1
database?
a. Any candidate key is eligible to become a primary key.
b. A primary key uniquely identifies the tuples in a relation.
c. A candidate key that is not a primary key is a foreign key.
d. A foreign key is an attribute whose value is derived from the primary
key of another relation.
15 1
Find and write the output of the following Python code:
TXT = ["20","50","30","40"]
CNT = 3 TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float(T) + C
print(TOTAL) CNT - = 1
16 Which of the following functions changes the position of file pointer and 1
returns its new position?
a.flush()
b.tell()
c.seek()
d.offset()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark
the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion(A): List is an immutable data type 1
Reasoning(R): When an attempt is made to update the value of an
immutable variable, the old variable is destroyed and a new variable is
created by the same name in memory.
18 Assertion(A): Python Standard Library consists of various modules. 1
Reasoning(R): A function in a module is used to simplify the code and
avoids repetition.
SECTION B
19 (i) Expand the following terms: 1+1=
2
POP3 , URL
(ii) Give one difference between XML and HTML.
OR
(i) Define the term bandwidth with respect to networks.
(ii) How is http different from https?
20 2
Find the output of following:
(2)
colors=["violet", "indigo", "blue", "green",
"yellow", "orange", "red"] del colors[4]
colors.remove(
"blue")
colors.pop(3
)
print(colors
)
21 Write a function countNow(PLACES) in Python, that takes the 2
dictionary, PLACES as an argument and displays the names (in
uppercase)of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New
York",5:"Doha"}
The output should be:
LONDON
NEW YORK
OR
Write a function, lenWords(STRING), that takes a string as an argument
and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the
tuple will have (4, 3, 2, 4, 4, 3)
22 2
Find the output of the following:
str = "Pythonforbeginners
is easytolearn" str2 =
"easy"
print("The first occurrence of str2 is
at : ", end="") print(str.find(str2,
4))
print("The last occurrence of str2 is
at : ", end="")
print(str.rfind(str2, 4))
23 1+1=
Rewrite the following Python program after removing all the syntactical errors (if any),
underlining each correction:
2
def checkval:
x = input("Enter a number")
if x % 2 = 0:
print x, "is even"
else if x<0;
print x, "should be positive" else; print x, "is odd"
24 Ms. Shalini has just created a table named “Employee” 2
containing columns Ename, Department and Salary.
After creating the table, she realized that she has forgotten to add a primary
key column in the table. Help her in writing an SQL command to add a
primary key column EmpId of integer type to the table Employee.
Thereafter, write the command to insert the following record in the table:
EmpId- 999
Ename- Shweta
Department:
Production Salary:
26900
25 Predict the output of the following code: 2
SECTION C
26 Predict the output of the Python code given below: 3
def makenew(mystr):
newstr = " "
count = 0
for i in mystr:
if count%2 != 0:
newstr = newstr + str(count)
else:
if i.islower():
newstr = newstr + i.upper()
else: newstr = newstr + i
count += 1
newstr = newstr + mystr[:1]
print("The new string is:", newstr)
makenew("sTUdeNT"
27 1*5=
Table COACHING is shown below. Write commands in SQL for (i) to (iii) and output for (iv)
5
and (v).
Table: COACHING
ID NAME AGE CITY FEE PHONE
P1 SAMEER 34 DELHI 45000 9811076656
P2 ARYAN 35 MUMBAI 54000 9911343989
P4 RAM 34 CHENNAI 45000 9810593578
P6 PREMLATA 36 BHOPAL 60000 9910139987
P7 SHIKHA 36 INDORE 34000 9912139456
P8 RADHA 33 DELHI 23000 8110668888
(i) Write a query to display name in descending order whose age is more
than 23.
(ii) Write a query to find the average fee grouped by age from customer
table.
(iii) Write query details from coaching table where fee is between 30000 and
40000.
(iv) Select sum(Fee) from coaching where city like “%O% ;
(v) Select name, city from coaching group by age having count(age)>2;
28 Write a function in Python to read a text file, Alpha.txt and displays 3
those lines which begin with the word ‘You’.
OR
Write a function, vowelCount() in Python that counts and displays the
number of vowels in the text file named Poem.txt.
30 A list, NList contains following record as list elements: 04
[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the
following user defined functions in Python to perform the specified
operations on the stack named travel.
(i) Push_element(NList): It takes the nested list as an
argument and pushes a list object containing name of the city and
country, which are not in India and distance is less than 3500 km
from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays
them. Also, the function should display “Stack Empty” when there
are no elements in the stack.
For example: If the nested list contains the following data:
NList=[["New York", "U.S.A.", 11734],
["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194],
["London", "England", 6693],
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty
SECTION D
31 Consider the tables PRODUCT and BRAND given below: 1*4=
4
Table: PRODUCT
PCode PName UPrice Rating BID
P01 Shampoo 120 6 M03
P02 Toothpaste 54 8 M02
P03 Soap 25 7 M03
P04 Toothpaste 65 4 M04
P05 Soap 38 5 M05
P06 Shampoo 245 6 M05
Table: BRAND
BID BName
M02 Dant Kanti
M03 Medimix
M04 Pepsodent
M05 Dove
Write SQL queries for the following:
(i) Display product name and brand name from the tables PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order of rating.
32 Vedansh is a Python programmer working in a school. For the Annual
Sports Event, he has created a csv file named Result.csv, to store the
results of students in different sports events. The structure of Result.csv
is :
[St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost'
or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the
following user defined functions:
Accept() – to accept a record from the user and add it to the file
Result.csv. The column headings should also be added on top of the csv
file.
wonCount() – to count the number of students who have won any
event. As a Python expert, help him complete the task.
04
SECTION E
33 (g) Riana Medicos Centre has set up its new centre in Dubai. It has four buildings as shown in the 1*5=
diagram given below 5
Research
Accounts
Lab
Packaging
Store
Unit
Distance between various buildings is as follows:
Accounts to Research Lab 55 m
Accounts to Store 150 m
Store to Packaging Unit 160 m
Packaging Unit to Research 60 m
Lab
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m
Number of computers:
Accounts 25
Research Lab 100
Store 15
Packaging Unit 60
As a network expert, provide the best possible answer to the
following queries:
(h) Suggest the type of network established between the
buildings.
(ii) Suggest the most suitable place (i.e., building) to house
the server of this organization.
(iii) Suggest the placement of the following devices with
justification: Repeater, Switch
(iv) Suggest a system (hardware/software) to prevent
unauthorized access to or from the network.
(v) Draw the cable layout for the connection.
34 (i) Differentiate between r+ and w+ file modes in Python. 2+3=
5
(ii) Consider a file, SPORT.DAT, containing records of the following
structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file
SPORT.DAT and copies the records with Sport name as “Basket Ball”
to the file named BASKET.DAT. The function should return the total
number of records copied to the file BASKET.DAT.
OR
(i) How are text files different from binary files?
(ii) A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype
as parameter and displays all the records from the binary file
CINEMA.DAT, that have the value of Movie Type as mtype.
35 (i) Define the term Domain with respect to RDBMS. Give one example 1+4=
5
to support your answer.
(ii) Kabir wants to write a program in Python to insert the following record in
the table named Student in MYSQL database, SCHOOL:
rno(Roll number )- integer
name(Name) - string
DOB (Date of birth) – Date
Fee – float
Note the following to establish connectivity between Python and MySQL:
Username - root
Password - tiger
Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from the
user. Help Kabir to write the program in Python.
OR
(i) Give one difference between alternate key and candidate key.
(ii) Sartaj has created a table named Student in MYSQL database,
SCHOOL:
rno(Roll number )- integer
name(Name) - string
DOB (Date of birth) – Date
Fee – float
Note the following to establish connectivity between Python and MySQL:
Username - root
Password - tiger
Host - localhost
Sartaj, now wants to display the records of students whose fee is more
than 5000. Help Sartaj to write the program in Python.
(v)