XII-Preboard II - Computer Science-Jan 2023
XII-Preboard II - Computer Science-Jan 2023
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each.
8. All programming questions are to be answered using Python Language only.
SECTION- A
1. State True or False (1)
“Text file stores information in ASCII or Unicode characters”.
2. Consider the given expression: (1)
not True and False or True
Which of the following will be correct output if the given expression is evaluated?
a. True b. False c. NONE d. NULL
3. For a given declaration in Python as S=”WELCOME” (1)
Which of the following will be the correct output of print(S [1: :2])?
a. WEL b. COME c. WLOE d. ECM
4. Find the invalid identifier from the following: (1)
a. name b. CLass c. section d. break
5. Which of the following is not a correct Python statement to open a text file “Notes.txt” to write
content into it? (1)
a. F=open(‘Notes.txt’, ‘w’) b. F=open(‘Notes.txt’, ‘a’)
c. F=open(‘Notes.txt’, ‘A’) d. F=open(‘Notes.txt’, ‘w+’)
6. Which of the following statement(s) would give an error after executing the following code?
(1)
S= “Welcome to class XII” #Statement 1
print (S) #Statement 2
S= “Thank You” #Statement 3
S[0]= ‘@’ #Statement 4
S=S+ “Thank You” #Statement 5
Page |1
a. Statement 3 b. Statement 4 c. Statement 5 d. Statement 4 and 5
7. Given a list A = [34,234,20,70,30,67]. What will be the correct statement to take out the 3 rd
element from the list? (1)
a. A.pop(2) b. A.find(2) c. A.pop(-1) d. A.del(20)
8. Riya wants to transfer pictures from her mobile phone to her laptop. She uses Bluetooth
technology to connect both the devices. Which type of network (PAN/LAN/MAN/WAN) will be
formed in this case? (1)
9. The …………… command can be used to remove all records of a table along with the table
structure. (1)
a. Delete Table b. Drop Table c. Remove Table d. None of these
10. For a function header as follows: (1)
def Calc(X, Y=20):
Which of the following function calls will give an error?
a. Calc(15,25) b. Calc(X=15,Y=25) c. Calc(Y=25) d. Calc(X=25)
11. Select the correct output of the code: (1)
a= 5
b = a = 15
c = (a < 15)
print(“a = “, a)
print(“b = “, b)
print(“c = “, c)
a. a = 15 b. a=5
b = 15 b = 15
c= False c = True
c. Both a and b d. None of these
12. …………..command is used to remove primary key from a table in SQL. (1)
a. update b. remove c. alter d. drop
13. ……………is a communication methodology designed to deliver both voice and multimedia
communications over Internet Protocol. (1)
a. VoIP b. SMTP c. PPP d. HTTP
14. ……………is a non-key attribute, whose values are derived from the primary key of some
other table. (1)
a. Primary Key b. Alternate Key c. Foreign Key d. Candidate Key
15. The correct syntax of seek() is: (1)
a. file_object.seek(offset[,reference_point]) b. seek(offset[,reference_point])
c. seek(offset,file_object) d. seek.file_object(offset)
16. Name the List method/function available in Python which is used to remove the last element
from a list implemented Stack. Also, write an example using Python statements for removing the
last element of the list. (1)
Page |2
Q.17 and 18 are ASSERTION and REASONING based questions. Mark the correct choice as:
Page |3
23. a. Write the full forms of the following: (1)
i. PPP ii. CDMA
b. What is the use of a repeater? (1)
24. What will be the output of the following Python code? (2)
W=25
def Fun (Ch):
W=50
print (W, end=Ch)
W*=2
print (W, end=Ch)
print (W, end= “*”)
Fun ( “!”)
print (W)
OR
Find the output of the following Python code:
D={1: “One”, 2: “Two”, 3: “Three”}
L=[ ]
for K,V in D.items( ):
if V[0]== “T”:
L.append(K)
print (L)
25. What is join? What are the different kind of join? (2)
OR
Categorize the following commands as DDL or DML:
CREATE TABLE, INSERT, UPDATE, ALTER
SECTION- C
26. a. Consider the following tables: Student_Details and Branch (1+2)
Table: Student_Details
RNo Name Subject
101 Akhil Maths
102 Preeti Physics
103 Rudra Physics
Table: Branch
RNo City
101 Delhi
102 Mumbai
101 Nagpur
What will be the output of the following statement?
SELECT * FROM Student_Details NATURAL JOIN Branch;
Page |4
b. Write the output of the queries (i) to (iv) based on the table STUDENT given below:
Table: STUDENT
RollNo Name Class DOB Gender City Marks
1 Nandan 10 06-06-1995 M Agra 551
2 Saurabh 12 07-05-1993 M Mumbai 462
3 Sonal 11 06-05-1994 F Delhi 400
4 Trisha 12 08-08-1995 F Mumbai 450
5 Stuart 12 08-10-1995 M Delhi 369
6 Marina 11 12-12-1994 F Dubai 250
7 Neha 10 08-12-1995 F Moscow 377
8 Nishant 10 12-06-1995 M Moscow 489
Page |5
Table: Consumer
C_I Consumer_Nam Address S_ID
D e
1 Good Learner Delhi PL01
6 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Draw Well Delhi PL02
Page |6
Expected Wire distances between various locations:
Research Building to Admin Building 90 m
Research Building to Academic Building 80 m
Academic Building to Admin Building 15 m
Delhi Admission Office to Parampur 1450 Km
Campus
(i) Suggest to the authorities, the cable layout amongst various buildings inside the
university campus for connecting the buildings.
(ii) Suggest the most suitable place (i.e. building) to house the server of this organisation
with a suitable reason.
(iii) Suggest an efficient device to be installed in each of the buildings to connect all the
computers.
(iv) Suggest the most suitable (very high speed) service to provide data connectivity
between Admission Building located in Delhi and the campus located in Parampur.
(v) Which type of network is formed by connecting the computers of the three buildings
inside the university campus?
32. a. Find and write the output of the following python code: (2+3)
Msg1= “WeLcOME”
Msg2= “GUeSTs”
Msg3= “ ”
for i in range(0, len(Msg2)+1):
if Msg1[i]>="A" and Msg1[i]<="M":
Msg3=Msg3+Msg1[i]
elif Msg1[i]>="N" and Msg1[i]<="Z":
Msg3=Msg3+Msg2[i]
else:
Msg3=Msg3+ “*”
print (Msg3)
b. The code given below inserts the following record in the table Student:
RollNo- integer
Name- string
Marks- integer
Note the following to establish connectivity between Python and MySQL:
Username is root
Password is tiger
The table exists in a MySQL database named school
The details(RollNo, Name and Marks) are to be accepted from the user
Page |7
Write the following missing statements to complete the code:
Statement 1- to form the cursor object
Statement 2- to execute the command that inserts the record in the table Student
Statement 3- to add the record permanently in the database.
import mysql.connector as mysql
def sql_data( ):
con1=mysql.connect(host=“localhost”,user=“root”,password=“tiger”,database=“school”)
mycursor=………………………………………. #Statement 1
rno =int (input(“Enter Roll Number::”))
name =input( “Enter name::”)
marks =int (input(“Enter Marks::”))
query=”insert into Student values({ }, ‘{ }’, { })”.format(rno, name, marks)
…………………………………………………… #Statement 2
…………………………………………………… #Statement 3
print ( “Data Added Successfully”)
OR
a. Find and write the output of the following Python code:
def Display(str):
m= “ ”
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('[email protected]')
b. The code given below reads the following record from the table named Student and
displays only those records who have marks greater than 75.
RollNo- integer
Name- string
Marks- integer
Note the following to establish connectivity between Python and MySQL:
Username is root
Password is tiger
The table exists in a MySQL database named school
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Page |8
Statement 2 – to execute the query that extracts records of those students whose
marks are greater than 75.
Statement 3- to read the complete result of the query (records whose marks are
greater than 75) into the object named data, from the table Student in the database.
import mysql.connector as mysql
def sql_data( ):
con1=mysql.connect(host=“localhost”,user=“root”,password=“tiger”,database=“
school”)
mycursor=………………………………………. #Statement 1
print (“Students with marks greater than 75 are”)
…………………………………………………… #Statement 2
data= ……………………………………………. #Statement 3
for i in data:
print(i)
print ( )
33. What is the advantage of using a CSV file? (2+3)
Write a program to create a CSV file to store student data (Rollno, Name, Marks). Obtain
data from user and write 5 records into the file.
OR
Write a Program in Python that defines and calls the following user defined functions:
a) ADD() – To accept and add data of an student to a CSV file ‘record.csv’. Each record
consists of a list with field elements as rollno, name and marks to store student rollno,
student name and student marks respectively.
b) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’
whose marks is more than 75.
SECTION- E
34. A departmental store MyStore is considering to maintain their inventory using SQL to store
the data. As a database administrator,Abhay has decided that: (4)
Name of the database: mystore
Name of the table: STORE
The attributes of STORE are as follows:
Itemno: numeric
Itemname: character of size 20
Scode: numeric
Quantity: numeric
Table:STORE
Itemno Itemname Scode Quantity
2005 Sharpener 23 60
Classic
2003 Ball Pen 0.25 22 50
2002 Gel Pen Premium 21 150
2006 Gel Pen Classic 21 250
2001 Eraser Small 22 220
2004 Eraser Big 22 110
2009 Ball Pen 0.5 21 180
Page |9
i. Identify the attribute best suitable to be declared as a primary key.
ii. Write the degree and cardinality of the table STORE.
iii. Write SQL statements to:
a. Insert the following data into the attributes:
Itemno=2010, Itemname=”Note Book”, Scode= 25, Quantity=50
b. Increase the quantity to 500 of those items whose Itemname begins with ‘E’
35. Neetu works as an IT expert in VV Infotech Ltd. She has been assigned the job of generating
a report to count total number of records of Staff using ‘Staff.csv’ file. She has written a
program to read CSV file ‘Staff.csv’ which contains details of all the staff members. She has
written the following code. As an IT expert help her to successfully execute the given task.
(4)
import #Line 1
def CountStaff ( ): #To read data from the CSV file
with (‘Staff.csv’, newline= ‘ ’) as f : #Line 2
csv_reader=csv. (f) #Line 3
rows = [ ]
values = 0
for i in csv_reader:
if csv_reader.line_num = =0:
continue
rows.append (i)
values = len ( (csv_reader)) #Line 4
print (“No. of Records are:”, values)
a. Name the module she should import in Line 1.
b. Write the method that she should use to open the file to read data from it.
c. Fill in the blank in Line 3 to read data from a csv file.
d. Fill in the blank in Line 4 with the method to convert the data from the file into list.
*****************************************************
P a g e | 10