Page 1
2024
Pre-Board
QUESTION PAPER
CBSE BOARD / STATE
BOARDS
NCERT Based Syllabus
Download PDF
Page 2
Pre-Board Exam 2024 Question Paper
(SET 1)
Computer Science (083)
PRE BOARD EXAMINATION 2023-24
Class XII
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.
SECTION A
1. State True or False 1
“Dictionaries in python are mutable.”
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
4. Consider the given expression: 1
True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
5. Select the correct output of the code: 1
Str=”I will Succeed”
Page 3
lis=str.split(“ “)
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
6. Which of the following methods will give the current position of the file pointer? 1
(a)seek() (b)tell() (c)getloc()(d) None of the above
7. Fill in the blank: 1
Command is used to change the structure of the table in SQL.
(a)update (b)remove (c)alter (d)drop
8. Which of the following commands will delete the row of the table from MYSQL 1
database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
9. Which of the following statement(s) would give an error after 1
executing the following code?
T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5
10. Fill in the blank: 1
is an attribute or set of attributes eligible to become primary
key.
(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey
Page 4
(d) Alternate Key
11. The default mode of opening a file in pyhton 1
(a) append
(b) read
(c) write
(d) both b and c
12. Which of the following can be used as command to get the structure of a table in 1
mysql
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
(a)VoIP (b)SMTP (c)PPP (d)HTTP
14. What will the following expression be evaluated to in Python? 1
print(2**3**2//8)
(a)64.0 (b)64 (c)8 (d)None Of These
15. Which clause is used to apply conditions with GROUP BY 1
(a) WHERE
(b) HAVING
(c) LIKE
(d) None Of These
16. Which function is used to establish connection between python and SQL 1
database?
(a) connection
(b) connect
(c) getconnection
(d) getconnect
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
Page 5
(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):-Functions in a program increases the modularity and readability of the 1
program
Reasoning (R):-Usage of Functions increases the execution speed of the program
18. Assertion (A): If a file is opened in binary mode its contents are viewed as a sequence of 1
bytes.
Reason (R): A text file also can be opened in binary mode
SECTION B
19. Rahul has written a code to input a number and return its reverse. His code is having 2
errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
20. What do you mean by protocol? Give two examples 2
OR
What is a MODEM? Explain its use?
21. (a) Given is a Python string declaration: 1
Mystr=”I will win”
Write the output of: print(Mystr[2:6])
(b) Write the output of the code given below:
dictcount={“age1”:26,”age2”:32,”age3”:40} 1
sum=0
for key in dictcount:
sum=sum+dictcount[key]
print(sum)
22. Explain the use of ‘Primary Key’ in a Relational Database Management 2
System. Give example to support your answer.
23. (a) Write the full forms of the following: 2
(i) FTP (ii)TCP
(b) What is the use of POP3?
Page 6
24. Predict the output of the Python code given below: 2
def product(L1,L2):
p=0
for i in L1:
for j in L2:
p=p+i*j
return p
LIST=[1,2,3,4,5,6]
l1=[]
l2=[]
for i in LIST:
if(i%2==0):
l1.append(i)
else:
l2.append(i)
print(product(l1,l2))
OR
Predict the output of the Python code given below:
tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = []
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
25. Explain the use of DISTINCT keyword in python with appropriate example 2
OR
What is called DDL commands in mysql?Give examples?
SECTION C
26. a)Consider the following tables -Product and Supplier: 1+2
Table:Product
Pid pname sid
P1 pen S1
P2 ball S2
P3 pencil S3
Table:Supplier
Sid sname
S1 Anmol
S2 Aradhya
S3 Sunil
S4 Vishal
Page 7
What will be the output of the following statement?
SELECT * FROM product NATURAL JOIN SUPPLIER;
b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given below
Empid Empname Salary Deptid
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1
(i)SELECT DISTINCT deptid from Employee;
(ii)SELECT deptid,count(*),min(salary) from employee GROUP BY deptid HAVING
count(deptid)>2;
(iii)SELECT empname FROM employee WHERE salary>14000 ORDER BY empname;
(iv)SELECT SUM(SALARY) FROM Employee WHERE SALARY BETWEEN 15000
AND 18000;
27. Write a method COUNTLINES() in python to read lines from text file MYSTORY.TXT 3
and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature
The COUNTLINES() function should display output as:
The number of lines starting with letter T :2
OR
Write a function COUNTOWEL() IN PYTHON which should read each character of
a text file CHARACTER.TXT and display the count of vowels
Example:
If the file content is as follows:
Exam is going on well
The COUNTOWEL() function should display the output as: 7
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
Page 8
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204
AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain Brooke Italy
(i) SELECT Author_id, avg(price) from BOOK GROUP BY Author_id;
ii) SELECT MAX(price),MIN(price) from BOOK;
ii) SELECT Book_name,Author_name,country from BOOK B, AUTHOR A
WHERE B.Author_id = A.Author_id AND price>300;
iv) SELECT Author_name from AUTHOR WHERE Author_name LIKE “A%”;
29. Write a function EVEN_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named ‘even list’ that stores
even numbers in the list.
For example:
If L contains [1,2,3,4,5,6,7,8]
The even list will have - [2,4,6,8]
30. A list contains following record of a student: [student_name, 3
age, hostel]
Write the following user defined functions to perform given operations on the stack
named ‘stud_details’:
(i) Push_element() - To Push an object containing name and age of students
who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also,
display “Stack Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
OR
Page 9
A list named as Record contains following format of for students: [student_name, class,
city].
Write the following user defined functions to perform given operations on the stack
named ‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'],
[‘Kohli',11,'Mumbai'], ['Rohit',12,'Delhi'] ] and then Push an object containing Student
name, Class and City of student belongs to ‘Delhi’ to the stack Record and display and
return the contents of stack
(ii) Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”] [“Rahul”,
12,”Delhi”] ] and then to Pop all the objects from the stack and at last display “Stack
Empty” when there is no student record in the stack. Thus the output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty
SECTION D
31
Hi-tech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization
Shortest distance between the blocks Number of computers installed
are given below: in each block are as follows:
Admin 🡪 Accounts 300 meters Training 150
Block
Accounts 🡪training 150 meters Accounts 30
block
I 200 meters Admin Block 20
Admin 🡪 Training
Mumbai 🡪 Chennai 1300 KM
office
i)
Suggest the most suitable block to house the server at Chennai block for
best and effective connectivity.
Page 10
Suggest the type of network for the new training institute and draw
ii) the cable layout for the Chennai office 1
Suggest a hardware/software that would provide the data security for entire network
iii) region.
1
Suggest a device that shall be needed to provide wireless internet access to all smart
iv) phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai 1
v) office and Mumbai office
1
1
32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")
The code given below inserts the following record in the table Employee:
Empid – integer Name – string salary-float
Note the following to establish connectivity between Python
and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named Empolyee.
The details (Empid, Name, salary) are to be accepted from the user.
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 Employee.
Statement 3- to add the record permanently in the database
import mysql.connector
from mysql.connector import Error
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
Page 11
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid"))
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
OR
(a) Predict the output of the code givenbelow:
s="PREboardCS*2022!"
j=2
for i in s.split('*'):
k=i[:j]
if k.isupper():
j=j+1
elif k.isdigit():
j=j+2
else:
j=j+3
print(s [ j : : j ] )
(b) The code given below reads the following record from the table named
Employee and displays only those records who have Salary greater than
25000:
Note the following to establish connectivity between Python and MYSQL:
● Username is root
● Password is tiger
● The table exists in a MYSQL database named Employee.
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 those Employees who
have salary greater than 25000.
Statement 3- to read the complete result of the query (records whose salary greater
than 25000) into the object named records, from the table Employee in the
database.
import mysql.connector
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
Page 12
print("salary",row[2],end=" ")
print()
33. What is a csv file? 5
Write a Program in Python that defines and calls the following user defined functions:
(i) INSERT() – To accept and add data of a student to a CSV file ‘student.csv’.
Each record consists of a list with field elements as sid, name and marksto
store student id, name and marks respectively.
(ii) COUNTSTUDENTS() – To count the number of records present in theCSV
file named‘student.csv’.
OR
What is the purpose of delimiter?
Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of a product to a CSV file ‘product.csv’.
Each record consists of a list with elements as pid, pnameand priceto
storeproduct id, product name and pricerespectively.
(ii) search()- To display the records of the products whose price is more
than5000.
SECTION E
34. Rahul created following table TRAVEL to store the travel details 1+1+2
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 3 columns are added and 1rows are deleted from the table TRAVEL, 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
Page 13
110 BIMAL 28-11-2022 200 VOLVO BUS 40
b. Increase KM travelled by 10 if the VTYPE is VOLVO.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of travel of traveler NANDA.
b. Add a column MILEAGE in the table with data type as integer
35. Biplab is a Python programmer. He has written a code and created a binary file
STUDENT.DAT which has structure (admission_number, Name, Percentage). He has
written an incomplete function countrec() in Python that would read contents of the file
“STUDENT.DAT” and display the details of those students whose percentage is above
75. Also display number of students scoring above 75%.As a Python expert, help him to
complete the following code based on the requirement given above:
import __________#statement1
def countrec():
_____________________#Statement2
records=_______________#Statement3
count=0
for record in records:
if(_______________):#Statement4
count=count+1
print("ID",record[0])
print("NAME",record[1])
print("PERCENTAGE",record[2])
print("No of students with perentage above 75",count)
1
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a file named STUDENT.DAT in 1
binary mode (Statement2)
(iii) Which statement should Biplab fill in Statement 3 to read the
data from the binary file, STUDENT.DATand in Statement 4 to check the percentage?
OR 2
Explain various functions used in writing rows in csv file.
Page 14
(SET 1)
Computer Science (083)
PRE BOARD EXAMINATION
MARKING SCHEME
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 Q34 against part only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. State True or False 1
“Dictionaries in python are mutable.”
Ans:True
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new
Ans:c def
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
Ans: c dict.keys()
4. Consider the given expression: 1
True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Ans:A True
5. Select the correct output of the code: 1
Str=”I will Succeed”
Page 15
lis=str.split(““)
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
ANS:c Succeed
6. Which of the following methods will give the current position of the file pointer? 1
(a)seek() (b)tell() (c)getloc() (d) None of the above
ANS:b tell()
7. Fill in the blank: 1
command is used to change the structure of the table in SQL.
(a)update (b)remove (c)alter (d)drop
ANS: c alter
8. Which of the following commands will delete the contents of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
ANS:a DELETE
9. Which of the following statement(s) would give an error after 1
executing the following code?
T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5
ANS:b statement 4
Page 16
10. Fill in the blank: 1
is an attribute or set of attributes eligible to become primary
key.
(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey
(d) Alternate Key
ANS:c candidate key
11. The default mode of opening a file in pyhton 1
(a) append
(b) read
(c) write
(d) both b and c
ANS:b read
12. Which of the following can be used as command to get the structure of a table in 1
mySQL
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
ANS:a DESCRIBE
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
(a)VoIP (b)SMTP (c)PPP (d)HTTP
ANS:b SMTP
14. What will the following expression be evaluated to in Python? 1
print(2**3**2//8)
(a)64.0 (b)64 (c)8 (d)None Of These
ANS: b 64
15. Which clause is used to apply conditions with GROUP BY 1
(a) WHERE
(b) HAVING
(c) LIKE
(d) None Of These
ANS:b HAVING
Page 17
16. Which function is used to establish connection between python and SQL 1
database?
(a) connection
(b) connect
(c) getconnection
(d) getconnect
ANS:b connect
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):-Functions in a program increases the modularity and readability of 1
the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program
ANS: c A is True but R is False
18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode
ANS: b Both A and R are true and R is not the correct explanation for A
SECTION B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
ANS:
def reverse():
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
Page 18
return rev
½ marks for each correction
20. What do you mean by protocol? Give two examples 2
ANS:1 mark for the definition and 1 mark for the example
OR
What is a MODEM? Explain its use?
ANS:MODULATOR DEMODULATOR
2marks for correct explanation.
21. (a) Given is a Python stringdeclaration: 1
Mystr=”I will win”
Write the output of: print(Mystr[2:6])
ANS:will 1
(b) Write the output of the code givenbelow:
dictcount={“age1”:26,”age2”:32,”age3”:40}
sum=0
for key in dictcount:
sum=sum+dictcount[key]
print(sum)
ANS:98
22. Explain the use of ‘Primary Key’ in a Relational Database Management 2
System. Give example to support your answer.
1 mark for example and 1 mark for explanation
23. (a) Write the full forms of thefollowing: 2
(i) FTP (ii)TCP
(b) What is the use of POP3?
ANS:FTP-FILE TRANSFER PROTOCOL ½ MARKS
TCP-TRANSMISSION CONTROL PROTOCOL ½ MARKS
1 MARK FOR THE EXPLANATION OF POP3
24. Predict the output of the Python code given below: 2
def product(L1,L2):
p=0
for i in L1:
for j in L2:
p=p+i*j
return p
LIST=[1,2,3,4,5,6]
l1=[]
l2=[]
for i in LIST:
Page 19
if(i%2==0):
l1.append(i)
else:
l2.append(i)
print(product(l1,l2))
ANS:108
OR
Predict the output of the Python code given below:
tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = []
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
ANS: (44, 42, 54, 65)
25. Explain the use of DISTINCT keyword in python with appropriate example 2
ANS:DISTINCT keyword discards duplicate vales
1 mark for explanation and 1 mark for example
OR
What is called DDL commands in mySQL?Give examples?
DDL-DATA DEFENITION LANGUAGE
EXAMPLE:CREATE ,DROP,ALTER
SECTION C
26. a)Consider the following tables -Product and Supplier: 1+2
Table:Product
Pid pname sid
P1 pen S1
P2 ball S2
P3 pencil S3
Table:Supplier
Sid sname
S1 Anmol
S2 Aradhya
S3 Sunil
S4 Vishal
What will be the output of the following statement?
SELECT * FROM product NATURAL JOIN SUPPLIER;
ANS:
Pid pname sid Sname
Page 20
P1 Pen S1 Anmol
P2 Ball S2 Aradhya
P3 Pencil S3 Sunil
b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given
below
Empid Empname Salary Deptid
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1
(i)SELECT DISTINCT deptid from Employee;
(ii)SELECT deptid,count(*),min(salary) from employee GROUP BY deptid
HAVING count(deptid)>2;
(iii)SELECT empname FROM employee WHERE salary>14000 ORDER BY
empname;
(iv)SELECT SUM(SALARY) FROM Employee WHERE SALARY BETWEEN
15000 AND 18000;
ANS:(i)
Deptid
D1
D2
D3
1/2 marks
(ii)
Deptid count(*) min(salary)
D1 3 12000
1/2 marks
(iii)
Empname
Aron
Debraj
1/2 marks
(iv)
Sum(Salary)
33000
1/2 marks
27. Write a method COUNTLINES() in python to read lines from text file 3
MYSTORY.TXT and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
Page 21
We should protect trees
This way we can serve nature
The COUNTLINES() function should display output as:
The number of lines starting with letter T :2
ANS:
def COUNTLINES():
fp=open("MYSTORY.TXT","r")
count=0
lines=fp.readlines()
for line in lines:
if(line[0]=="T"):
count=count+1
print("The number of lines starting with letter T :",count)
OR
Write a function COUNTOWEL() IN PYTHON which should read each
character of a text file CHARACTER.TXT and display the count of vowels
Example:
If the file content is as follows:
Exam is going on well
The COUNTOWEL() function should display the output as:
7
ANS:
def COUNTVOWELS():
fp=open("CHARACTER.TXT","r")
count=0
characters=fp.read()
characters=characters.lower()
for character in characters:
if(chatacter in ['a','e','i','o','u']):
count=count+1
print(count)
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204
Page 22
AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain&BrookeItaly
(i) SELECT Author_id, avg(price) FROMBOOK GROUP
BYAuthor_id;
ii) SELECT MAX(price),MIN(price) FROM BOOK;
ii) SELECTBook_name,Author_name,countryFROM BOOK B,
AUTHOR A WHERE B.Author_id = A.Author_idANDprice>300;
iv) SELECT Author_name FROM AUTHOR WHERE Author_nameLIKE
“A%”;
ANS:
(i)
Author_id Avg(price)
204 420.5
202 462
203 248
(ii)
MAX(price) MIN(price)
518 248
(iii)
Book_name Author_nam Country
e
My First Brain&Broo Italy
C++ ke
SQL Basics Anita India
The Tears Brain&Broo Italy
ke
(iv)
Author_name
Anita
Anna Roberts
29. Write a function EVEN_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named ‘evenlist’
Page 23
that stores even numbers in the list.
For example:
If L contains [1,2,3,4,5,6,7,8]
The evenlist will have - [2,4,6,8]
ANS:
def EVEN_LIST(L):
evenlist=[]
for i in L:
if(i%2==0):
evenlist.append(i)
return evenlist
30. A list contains following record of a student: 3
[student_name, age, hostel]
Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing nameand
age of students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in
thestack.
For example:
If the lists of customer detailsare:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
ANS:
stud_details=[]
def push_element(lis):
if(lis[2]=="Ganga"):
stud_details.append([lis[0],lis[1]])
def pop_element():
while(len(stud_details)>0):
print(stud_details.pop())
print("Stack Empty")
OR
Page 24
def Push_record(): # (1½ mark for correct push element)
for i in List:
if i[2]=="Delhi":
Record.append(i)
print(Record)
def Pop_record(): # (1½ mark for correct push element)
while True:
if len(Record)==0:
print('Empty Stack')
break
else:
print(Record.pop())
Push(Dict_Product)
(1 mark for correct function header
1 mark for correct loop
½ mark for correct If statement
½ mark for correct display of count)
SECTION D
31
HiTech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization
Shortest distance between the blocks Number of computers installed
are given below: in each block are as follows:
Admin 🡪 Accounts 300 meters Training 150
Block
Accounts 🡪training 150 meters Accounts 30
block
I 200 meters Admin Block 20
Admin 🡪 Training
Page 25
Mumbai 🡪 Chennai 1300 KM
office
i)
Suggest the most suitable block to house the server at Chennai block for
ii) 1
best and effective connectivity.
Suggest the type of network for the new training institute and draw 1
iii)
the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security 1
iv)
for entire network of Chennai region.
Suggest a device that shall be needed to provide wireless
v) 1
internet access to all smart phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
1
office and Mumbai office
ANS:
i)Training Block
ii)LAN
iii)FIREWALL
iv)ACCESS POINT
v)H.323 or SIP
32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")
ANS:4-4-
) The code given below inserts the following record in the table
Employee:
Empid – integer Name – string salary-float
Note the following to establish connectivity
between Python and MYSQL:
Username is root
Page 26
Password is tiger
The table exists in a MYSQL database named Empolyee.
The details (Empid, Name, salary) are to be accepted from
the user.
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 Employee.
Statement 3- to add the record permanently in
the database
import mysql.connector
from mysql.connector import Error
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid"))
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
ANS:
STATEMENT1:connection.cursor()
STATEMENT2:cursor.execute("insert into employee
values(%s,%s,%s)",(empid,name,salary))
STATEMENT3:connection.commit()
OR
(a) Predict the output of the code givenbelow:
s="PREboardCS*2022!"
j=2
for i in s.split('*'):
k=i[:j]
if k.isupper():
j=j+1
elif k.isdigit():
j=j+2
else:
j=j+3
print(s [ j : : j ] )
ANS:
brS0!
(b) The code given below reads the following record from thetable
named Employeeand displays only those records who have Salary
greater than 25000:
Page 27
Note the following to establish connectivity between Python and
MYSQL:
● Username isroot
● Password istiger
● The table exists in a MYSQL database namedEmployee.
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 those
Employees who have salary greater than 25000.
Statement 3- to read the complete result of the query (records whose salary
greater than 25000) into the object named records, from the table
Employeein the database.
import mysql.connector
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()
ANS:
Statement 1 :connection.cursor()
Statement 2 :cursor.execute("select * from employee where salary>25000")
Statement 3:cursor.fetchall()
33. What is a csv file? 5
Write a Program in Python that defines and calls the following user defined
functions:
(i) INSERT() – To accept and add data of a student to a CSV file
‘student.csv’. Each record consists of a list with field elements as sid,
name and marksto store student id, name and marks respectively.
(ii) COUNTSTUDENTS() – To count the number of records present in
theCSV file named‘student.csv’.
ANS:
import csv
def INSERT():
studlist=[]
while(choice=="y"):
sid=int(input("Enter Student id"))
name=input("Enter name")
marks=input("Enter Marks")
choice=input("Enter y to continue or press any to exit")
student=[sid,name,marks]
Page 28
studlist.append(student)
file=open("student.csv","w")
writer=csv.writer(file)
writer.writerows(studlist)
def COUNTSTUDENTS():
file=open("student.csv","r")
reader=csv.reader(file)
print("No of students",len(reader))
OR
What is the purpose of delimiter?
Write a Program in Python that defines and calls the following user defined
functions:
(i) add() – To accept and add data of a product to a CSV file
‘product.csv’. Each record consists of a list with elements as
pid, pnameand priceto storeproduct id, product name and
pricerespectively.
(ii) search()- To display the records of the products whose price is
more than5000.
ANS:
import csv
def add():
prodist=[]
while(choice=="y"):
pid=int(input("Enter product id"))
pname=input("Enter name")
price=input("Enter price")
choice=input("Enter y to continue or press any to exit")
product=[pid,pname,price]
prodlist.append(product)
file=open("product.csv","w")
writer=csv.writer(file)
writer.writerows(prodlist)
def search():
file=open("product.csv","r")
reader=csv.reader(file)
for record in reader:
if(record[2]>5000):
print("Product id",record[0])
print("Product name",record[1])
print("Product price",record[2])
1 mark for correct explanation of question
½ marks for correctly opening the file
½ marks for creating reader and writer objects
Page 29
Full marks for correct code
SECTION E
34. Rahul created following table TRAVEL to store the travel details 1+1+2
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 3 columns are added and 1rows are deleted from the table TRAVEL,
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
110 BIMAL 28-11-2022 200 VOLVO BUS 40
(b) Increase KM travelled by 10 if the VTYPE is VOLVO.
ANS:
a)(i)TNO (ii)degree-9 cardinality-6
iii)a.INSERT INTO TRAVEL
VALUES(110,’BIMAL’,’28-11-2022’,200,’VOLVOBUS’,40)
b.UPDATE TRAVEL SET KM=KM+10 WHERE VTYPE=’VOLVO
BUS’
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of travel of traveler NANDA.
b. Add a column MILEAGE in the table with data type as
integer
ANS:
a)DELETE FROM TRAVEL WHERE TNAME=’NANDA’
Page 30
b)ALTER TABLE TRAVEL ADD(MILEAGE int)
35. Biplab is a Python programmer. He has written a code and created a binary file
STUDENT.DAT which has structure (admission_number, Name, Percentage).
He has written an incomplete function countrec() in Python that would read
contents of the file “STUDENT.DAT” and display the details of those students
whose percentage is above 75. Also display number of students scoring above
75%.As a Python expert, help him to complete the following code based on the
requirement given above:
import __________#statement1
def countrec():
_____________________#Statement2
records=_______________#Statement3
count=0
for record in records:
if(_______________):#Statement4
count=count+1
print("ID",record[0])
print("NAME",record[1])
print("PERCENTAGE",record[2])
print("No of students with perentage above 75",count)
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a file named 1
STUDENT.DAT. in binary mode (Statement2)
(iii) Which statement should Biplab fill in Statement 3 to readthe 1
data from the binary file, STUDENT.DATand in Statement 4 to check the
percentage?
ANS 2
(i) pickle
(ii)fp=open("STUDENT.DAT","rb")
(iii)records=pickle.load(fp)
if(record[2]>75)
AglaSem Earn while Learn Program. Send your papers and get paid.
Contact: support@
Page 31
QUESTION PAPERS
GET PREVIOUS YEAR QUESTION PAPERS FOR ALL CLASSES FOR CBSE, ISCSE, ISC AND ALL ALL
STATE BOARDS HERE AT
Andhra Pradesh Board Question Papers
BOARD
WISE Assam Board Question Papers
Bihar Board Question Papers
Chhattisgarh Board Question Papers
Goa Board Question Papers
Gujarat Board Question Papers
Haryana Board Question Papers
Himachal Pradesh Board Question Papers
J&K State Board Question Papers
Jharkhand Board Question Papers
Karnataka Board Question Papers
Kerala Board Question Papers
Madhya Pradesh Board Question Papers
Maharashtra State Board Question Papers
Manipur Board Question Papers
Meghalaya Board Question Papers
Mizoram Board Question Papers
Nagaland Board Question Papers
Orissa Board Question Papers
Punjab Board Question Papers
Rajasthan Board Question Papers
Tamil Nadu Board Question Papers
Telangana State Board Question Papers
Tripura Board Question Papers
Uttarakhand Board Question Papers
Uttar Pradesh (UP) Board Question Papers
West Bengal (WB) Board Question Papers