Class: XII
Session: 2022-23
Computer Science (083)
PRE-BOARD EXAMINATION
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 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. One internal choice is
given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.
QNo SECTION-A Marks
1 Which command comes under TCL(Transaction Control Language)? 1
(a)alter (b)update (c) grant (d) create
2 Which of the following is an invalid datatype in Python?
(a) list (b) Dictionary (c)Tuple (d)Class 1
3 Given the following dictionaries
dict_fruit={"Kiwi":"Brown", "Cherry":"Red"}
dict_vegetable={"Tomato":"Red", "Brinjal":"Purple"}
Which statement will merge the contents of both dictionaries? 1
(a) dict_fruit.update(dict_vegetable) (b) dict_fruit + dict_vegetable
(c) dict_fruit.add(dict_vegetable) (d) dict_fruit.merge(dict_vegetable)
4 Consider the given expression:
not False and False or True
Which of the following will be correct output if the given expression is 1
evaluated?
True b.False c. NONE d. NULL
5 Select the correct output of the code:
(a) 0 1 2 ….. 15 (b)Infinite loop
(c) 0 3 6 9 12 15 (d) 0 3 6 9 12
6 Which of the following is not a valid mode to open a file?
1
(a) ab (b) r+ (c) w+ (d) rw
7 Fill in the blank:
command is used to delete the table from the database of SQL. 1
(a) update (b)remove (c) alter (d) drop
8 Which of the following commands will use to change the structure of table in
MYSQL database?
(a)DELETE TABLE (b)DROP TABLE 1
(c)REMOVE TABLE (d)ALTER TABLE
9 What possible output(s) are expected to be displayed on screen at the time of
execution of the program from the following code?
import random
points=[20,40,10,30,15]
points=[30,50,20,40,45]
begin=random.randint(1,3) 1
last=random.randint(2,4)
for c in range(begin,last+1):
print(points[c],"#")
(a) 20#50#30# (b) 20#40#45
(c) 50#20#40# (d) both (b) and (c)
10 Fill in the blank:
is an attribute whose value is derived from the primary key
of some other table.
1
(a) Primary Key (b) Foreign Key
(c) Candidate Key (d) Alternate Key
11 The tell() function returns:
(a) Number of bytes remaining to be read from the file
(b) Number of bytes already read from the file
(c) Number of the byte written to the file 1
(d) Total number of bytes in the file
12 Fill in the blank:
The SELECT statement when combined with_________function,
returns number of rows present in the table. 1
(a) DISTINCT (b) UNIQUE (c) COUNT (d) AVG
13 Which switching technique follows the store and forward mechanism?
(a) Circuit switching (b) message switching
1
(c) packet switching (d) All of these
14 What will the following expression be evaluated to in Python?
print(16-(3+2)*5+2**3*4) 1
(a) 54 (b) 46 (c) 23 (d) 32
15 Which function is used to display the unique values of a column of a table?
1
(a) sum() (b) unique() (c)distinct() (d)return()
16 To establish a connection between Python and SQL database, connect() is
used. Which of the following value can be given to the keyword argument –
host, while calling connect ()?
(a) localhost 1
(b) 127.0.0.1
(c) any one of (a) or (b)
(d) localmachine
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
1
(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):- key word arguments are related to the function calls.
Reasoning (R):- when you use keyword arguments in a function call, the 1
caller identifies the arguments by parameter name.
18 Assertion (A): CSV stands for Comma Separated Values
Reason (R): CSV files are a common file format for transferring and storing 1
data.
SECTION-B
19 Observe the following Python code very carefully and rewrite it after 2
removing all syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)== x)
print("You entered a positive number")
else:
x=*1
print("Number made positive:" x )
20 Write two differences between Coaxial and Fiber transmission media. 2
OR
Write components of data communication.
21 (a) Given is a Python string declaration: 1+1 =2
message="Bring it on!!!"
Write the output of: print(message[::-2])
(b) Write the output of the code given below:
book_dict = {"title": "You can win", “copies”:15}
book_dict['author'] = “Shiv Khera”
book_dict['genre'] = "Motivation"
print(book_dict.items())
22 How many candidate key and primary key a table can have? Can we declare 2
combination of fields as a primary key?
23 (a) Write the full forms of the following: 1+1=2
(i) FTP (ii) MAC
(b) What is the use of TELNET?
24 Predict the output of the Python code given below: 2
def Swap (a,b ) :
if a>b:
print(“changed ”,end=“”)
return b,a
else:
print(“unchanged ”,end=“”)
return a,b
data=[11,22,16,50,30]
for i in range (4,0,-1):
print(Swap(data[i],data[i-1]))
OR
Predict the output of the Python code given below:
P = (10, 20, 30, 40, 50 ,60,70,80,90)
Q =list(P)
R = []
for i in Q:
if i%3==0:
R.append(i)
R = tuple(R)
print(R)
25 Differentiate between DDL and DML commands with suitable example. 2
OR
What is the difference between WHERE and HAVING clause of SQL
statement?
SECTION – C
26 (a)Consider the following tables – Bank_Account and Branch:
Bank_Account: 1+2=3
ACode Name Type
A01 Amit Savings
A02 Parth Current
A03 Mira Current
Branch:
ACode City
A01 Delhi
A02 Jaipur
A01 Ajmer
What will be the output of the following statement?
SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b) Give the output of the following sql statements as per table given above.
Table : SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C
i. SELECT COUNT(*) FROM SPORTS.
ii. SELECT DISTINCT Class FROM SPORTS.
iii. SELECT MAX(Class) FROM SPORTS;
iv. SELECT COUNT(*) FROM SPORTS GROUP BY Game1;
27 Write a method COUNTLINES() in Python to read lines from text file 1+2
‘TESTFILE.TXT’ and display the lines which are starting with any article (a,
an, the) insensitive of the case.
Example:
If the file content is as follows:
Give what you want to get.
We all pray for everyone’s safety.
A marked difference will come in our country.
The Prime Minister is doing amazing things.
The COUNTLINES() function should display the output as:
The number of lines starting with any article are : 2
OR
Write a function GPCount() in Python, which should read each character
of a text file “STORY.TXT” and then count and display the count of
occurrenceof alphabets G and P individually (including small cases g and
p too).
Example:
If the file content is as follows:
God helps those who help themselves.
Great way to be happy is to remain positive.
Punctuality is a great virtue.
The GPCount() function should display the output as:
The number of G or g: 3
The number of P or p : 6
28 (a) consider the following tables School and Admin and answer the following 2+1=3
questions:
TABLE: SCHOOL
CODE TEACHER SUBJECT DOJ PERIODS EXPERIENCE
1001 RAVI ENGLISH 12/03/2000 24 10
1009 PRIYA PHYSICS 03/09/1998 26 12
1203 LISA ENGLISH 09/04/2000 27 5
1045 YASH RAJ MATHS 24/08/2000 24 15
1123 GAGAN PHYSICS 16/07/1999 28 3
1167 HARISH CHEMISTRY 19/10/1999 27 5
1215 UMESH PHYSICS 11/05/1998 22 16
TABLE : ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD
Give the output of the following SQL queries:
i. Select Designation, count(*) from Admin Group by Designation
having count(*)<2;
ii. Select max(experience) from school;
iii. Select teacher from school where experience >12 order by teacher;
iv. Select count(*), gender from admin group by gender;
(b) Write SQL command to delete a table from database.
29 Write a function Lshift(L), where L is the list of elements passes as an 3
argument to the function. The function shifts all the elements by one place
to the left and then print it.
For example:
If L contains [9,4,0,3,11,56]
The function will print - [4,0,3,11,56,9]
30 Write Add_New(Book) and Remove(Book) methods in Python to Add a new 1+2
Book and Remove a Book from a List of Books, considering them to act as
PUSH and POP operations of the data structure stack.
OR
Aalia has a list containing 10 integers. You need to help him create a program
with separate user defined functions to perform the following operations
based on this list.
➢ Traverse the content of the list and push the even numbers into a stack.
➢ Pop and display the content of the stack.
For example:
If the sample content of the list is as follows:
N=[12,13,34,56,21,79,98,22,35,38]
Sample output of the code should be:
38 22 98 56 34 12
SECTION – D
31 Trine Tech Corporation (TTC) is a professional consultancy company. The 5
company is planning to set up their new offices in India with its hub at
Hyderabad. As a network adviser, you have to understand their requirement
and suggest them the best available solutions. Their queries
are mentioned
as (i) to (v) below.
a) Which will be the most appropriate block, where TTC should plan to
install their server?
b) Draw a block to block cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
c) What will be the best possible connectivity out of the following, you will
suggest to connect the new setup of offices in Bengalore with its London
based office.
● Satellite Link
● Infrared
● Ethernet
d) Which of the following device will be suggested by you to connect each
computer in each of the buildings?
● Switch
● Modem
● Gateway
e) Company is planning to connect its offices in Hyderabad which is less than
1 km. Which type of network will be formed?
32 (a) Write the output of the code given below: 2+3=5
(b)The code given below inserts the following record in the table
mobile:
import mysql.connector
mycon = mysql.connector.connect (host = “localhost”, user = “Admin”,
passwd = “Admin@123”, database = “connect”)
cursor = mycon. () # Statement 1
sql = “INSERT INTO Mobile (Name, Model, Price, Qty) VALUES (%s, %s, %s,
%s)” val = (“Samsung”, “Galaxy Pro”, 28000, 3)
cursor… (sql,val) #Statement 2
mycon. #Statement 3
Write the missing statement: Statement1 , Statement2 and Statement3
OR
(a) Predict the output of the code given below:
(b) The code given below reads the following record from the tablenamed
student and displays only those records who have marks greater than
80:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python andMYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named kvs.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of thosestudents
whose marks are greater than 80.
Statement 3- to read the complete result of the query (records whose
marks are greater than 80) into the object named data, from thetable
studentin the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",passwo rd="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)
33 (a) What does CSV stand for? 1+2+2=
(b) Write a Program in Python that defines and calls the following user 5
defined functions:
(i) InsertRow() – To accept and insert data of an student to a CSV file
‘class.csv’. Each record consists of a list with field elements as rollno,
name and marks to store roll number, student’s name and marks
respectively.
(ii) COUNTD() – To count and return the number of students who
scored marks greater than 75 in the CSV file named ‘class.csv’.
OR
Dhirendra is a programmer, who has recently been given a task to write a
python code to perform the following CSV file operations with the help of
two user defined functions/modules:
a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode
containing information of books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field title starts with 'R'.
He has succeeded in writing partial code and has missed out certain
statements, so he has left certain queries in comment lines.
import csv
def CSVOpen():
with open('books.csv','_____',newline='') as csvf: #Statement-1
cw=_____________#Statement-2
__________________#Statement-3
cw.writerow(['Rapunzel','Jack',300])
cw.writerow(['Barbie','Doll',900])
cw.writerow(['Johnny','Jane',280])
def CSVRead():
try:
with open('books.csv','r') as csvf:
cr=_________________#Statement-4
for r in cr:
if : #Statement-5 print(r)
except:
print('File Not Found')
CSVOpen()
CSVRead()
You as an expert of Python have to provide the missing statements and
other related queries based on the following code of Raman.
(i) Choose the appropriate mode in which the file is to be opened in
append mode (Statement 1)
(ii) Which statement will be used to create a csv writer object in
Statement 2.
(iii) Choose the correct option for Statement 3 to write the names of the
column headings in the CSV file, BOOKS.CSV.
(iv)
(iv) Which statement will be used to read a csv file in Statement 4.
(v) Fill in the appropriate statement to check the field Title starting with
‘R’ for Statement 5 in the above program.
SECTION -E
34 Mayank creates a table RESULT with a set of records to maintain the marks 4
secured by students in sub1, sub2, sub3 and their GRADE. After creation of
the table, he has entered data of 7 students in the table.
Table : RESULT
ROLL_NO SNAME sub1 sub2 sub3 GRADE
101 KIRAN 366 410 402 I
102 NAYAN 300 350 325 I
103 ISHIKA 400 410 415 I
104 RENU 350 357 415 I
105 ARPITA 100 75 178 IV
106 SABRINA 100 205 217 II
107 NEELIMA 470 450 471 I
103 ISHIKA 400 410 415 I
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as
Primary key.
(ii) If two columns are added and 2 rows are deleted from the table result,
what will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 108, Name- Aaditi, sub1- 470, sub2-444, sub3- 475,
Grade– I.
b. Increase the sub2 marks of the students by 3% whose name
begins with ‘N’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students securing Grade-IV.
b. Add a column REMARKS in the table with datatype as varcharwith 50
characters.
4
Reshabh is a programmer, who has recently been given a task to write a
35
python code to perform the following binary file operations with the help of
two user defined functions/modules:
a. AddStudents() to create a binary file called STUDENT.DAT containing
student information – roll number, name and marks (out of 100) of each
student.
b. GetStudents() to display the name and percentage of those students
who have a percentage greater than 75. In case there is no student having
percentage > 75 the function displays an appropriate message. The function
should also display the average percent.
He has succeeded in writing partial code and has missed out certain
statements, so he has left certain queries in comment lines. You as an
expert of Python have to provide the missing statements and other related
queries based on the following code of Reshabh.
import pickle
def AddStudents():
_____________________# statement 1 to open the binary file to write data
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
__________________#statement 2 to write the list L into the file
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
___________________ #statement 3 to read from the file
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent =",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("No student has percentage more than 75")
print("average percent of class = ",_____________) #statement 4
AddStudents()
GetStudents()
(i) Which of the following commands is used to open the file “STUDENT.DAT”
for writing only in binary format? (marked as #1 in the Python code)
(ii) Which of the following commands is used to write the list L into the
binary file, STUDENT.DAT? (marked as #2 in the Python code)
(iii) Which of the following commands is used to read each record from the
binary file STUDENT.DAT? (marked as #3 in the Python code)
(iv) What expression will be placed in statement 4 to print the average
percent of the class.
************************