Class Xii Computer Science Mock Test Paper 01 QP
Class Xii Computer Science Mock Test Paper 01 QP
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
(a) True
(b) False
(c) NONE
(d) NULL
1
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
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
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
2
(d) Alternate Key
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
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
3
(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
OR
4
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
25. Explain the use of DISTINCT keyword in python with appropriate example 2
OR
SECTION C
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
OR
Example:
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
6
AUTHOR
If L contains [1,2,3,4,5,6,7,8]
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
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'],
7
[‘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
i) Suggest the most suitable block to house the server at Chennai block for 1
best and effective connectivity.
Suggest the type of network for the new training institute and draw
ii) 1
the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security for entire network of Chennai
1
iii) region.
Suggest a device that shall be needed to provide wireless internet access to all smart
8 1
iv) phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai 1
v) office and Mumbai office
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="-")
(b) The code given below inserts the following record in the table Employee:
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
9
OR
(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:
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=" ")
print("salary",row[2],end=" ")
print()
(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.
(i) COUNTSTUDENTS() – To count 10 the number of records present in theCSV
file named‘student.csv’.
OR
(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.
(i) 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
(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
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)
12