SQP 07 - QP
SQP 07 - QP
CLASS – XII
COMPUTER SCIENCE
SECTION A
1. Identify the incorrect variable name: (1)
a) int b) float c) while d) true
2. What will be the data type of of the expression 12/5==0? (1)
a) True b) False c) bool d) float
3. What will be output of the following code: (1)
d1={1:2,3:4,5:6}
d2=d1.get(3,5)
print(d2)
a) 3 b) 4 c) 5 d) Error
1
9. Select the correct output of the code: (1)
a = "assistance"
a = a.partition('a')
b = a[0] + "-" + a[1] + "-" + a[2]
print (b)
a) -a-ssistance b) -a-ssist-nce
c) a-ssist-nce d) -a-ssist-ance
10. Which of the following statement(s) would give an error during execution? (1)
S=("CBSE") # Statement 1
S+="Delhi" # Statement 2
S[0]= '@' # Statement 3
S=S+"Thank you" # Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
13. Which protocol is used for transferring files over a TCP/IP network? (1)
a) FTP b) SMTP c) PPP d) HTTP
14. What will the following expression be evaluated to in Python? (1)
27 % 7 // (3 / 2)
a) 2 b) 2.0 c) 4.0 d) 4
15. Which function cannot be used with string type data? (1)
a) min() b) max() c) count() d) sum()
16. In context of Python - Database connectivity, the function fetchmany()is a method of (1)
which object?
a) connection b) database c) cursor d) query
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
c) A is True but R is False
d) A is false but R is True
17. Assertion (A):- print(f1()) is a valid statement even if the function f1() (1)
has no return statement.
Reasoning (R):- A function always returns a value even if it has no return
statement.
18. Assertion (A): If L is a list, then L+=range(5)is an invalid statement.Reason (R): Only (1)
a list can be concatenated to a list.
SECTION B
2
19. Mohit has written a code to input a positive integer and display its factorial. His code is (2)
having errors. Rewrite the correct code and underline the corrections made. (factorial of
a number n is the product 1x2x3. . .n)
n=int(input("Enter a positive integer: ")
f=0
for i in range(n):
f*=i
print(f)
20. Write two points of difference between LAN and MAN. (2)
OR
21. (a) Write a Python statement to display alternate characters of a string, named (1)
my_exam. For example, if my_exam="Russia Ukraine"
The statement should display Rsi kan
22. Can a table in an RDBMS have multiple candidate keys? Can it have multiplePrimary (2)
keys? Give an example to support your answer.
23. (a) Write the full forms of the following: (i) VoIP (ii) IMAP (1)
(b) Name the communication medium which is used for WiFi. (1)
24. Predict the output of the Python code given below: (2)
def Alpha(N1): while
N1:
a=N1.pop()
if a%5>2: print(a,end='@') else: break
NUM=[13,24,12,53,34]
Alpha(NUM); print(NUM)
OR
Predict the output of the Python code given below:
T1 = tuple("Amsterdam")
T2, new_list = T1[1:-1], [] for i in T2:
if i in 'aeiou':
j=T1.index(i)
new_list+=[j]
print(new_list)
25. If a column score in a table match has five entries, viz. 30,65,NULL,40,NULL,then (2)
what will be the output of the following query?
Select count(*), avg(score) from match;
OR
Write two differences between HAVING and WHERE clauses in SQL.
3
SECTION C
26. (a) Consider the following table: (1)
Table: Employee
What is the degree and cardinality of table Employee, if it contains only the given
data? Which field fields is/are the most suitable to be the Primary key if the data
shown above is only the partial data? (2)
(b) Write the output of the queries (i) to (iv) based on the table Employee:
(i) select name, project from employee order by project;
(ii) select name, salary from employee where doj like'2015%';
(iii)select name, salary from employee where salary between 100000 and 200000;
(iv) select min(doj), max(dob) from employee;
27. Write a method count_words_e() in Python to read the content of a textfile and count (3)
the number of words ending with 'e' in the file.
Example: If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The count_words_e() function should display the output as:
No. of such words: 4
OR
Write a function reverseFile()in Python, which should read the content of a text file
“TESTFILE.TXT” and display all its line in the reverse order.
It rained yesterday.
It might rain today.
I wish it rains tomorrow too.
I love Rain.
.yadretsey deniar tI
.yadot niar thgim tI
.oot worromot sniar ti hsiw I
.niaR evol I
4
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relationsProjects (2)
and Employee given below:
(b) Write the command to make Projects column of employee table a foreign key (1)
which refers to PID column of Projects table.
29. Write a function AdjustList(L), where L is a list of integers. The function should reverse (3)
the contents of the list without slicing the list and without using any second list.
Example: If the list initially contains 2, 15, 3, 14, 7, 9, 19, 6, 1, 10,
then after reversal the list should contain 10, 1, 6, 19, 9, 7, 14, 3, 15, 2
5
30. A nested list contains the data of visitors in a museum. Each of the inner lists contains (3)
the following data of a visitor:
[V_no (int), Date (string), Name (string), Gender (String M/F), Age (int)]
Write the following user defined functions to perform given operations on the stack
named "status":
(i) Push_element(Visitors) - To Push an object containing Gender of visitor who
are in the age range of 15 to 20.
(ii) Pop_element() - To Pop the objects from the stack and count the display the
number of Male and Female entries in the stack. Also, display “Done” when
there are no elements in the stack.
For example: If the list Visitors contains:
[['305', "10/11/2022", “Geeta”,"F”, 35],
['306', "10/11/2022", “Arham”,"M”, 15],
['307', "11/11/2022", “David”,"M”, 18],
['308', "11/11/2022", “Madhuri”,"F”, 17],
['309', "11/11/2022", “Sikandar”,"M”, 13]]
The stack should contain
F
M
M
The output should be:
Done
Female: 1
Male: 2
OR
Write the following functions in Python:
(i) Push(st, expression), where expression is a string containing a valid
arithmetic expression with +, -, *, and / operators, and st is a list representing
a stack. The function should push all the operators appearing in this
expression into the stack st.
(ii) Pop(st) to pop all the elements from the stack st and display them.It should
also display the message 'Stack Empty' when the stack becomes empty.
For example: If the expression is:
42*5.8*16/24-8+2
Then st should contain
+
-
/
*
*
The output should be:
+ - / * * Stack Empty
6
31. FutureTech Corporation, a Bihar based IT training and development company, is
planning to set up training centers in various cities in the coming year. Their first center
is coming up in Surajpur district. At Surajpur center, they are planning to have 3
different blocks - one for Admin, one for Training and one for Development. Each
block has number of computers, which are required to be connected in a network for
communication, data and resource sharing. As a network consultant of this company,
you have to suggest the best network related solutions for them for issues/problems
raised in question nos. (i) to (v), keeping in mind the distances between various
blocks/locations and other given parameters.
(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur (1)
center (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center? (1)
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to (1)
most efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons: (1)
a) Switch/Hub b) Router
(v) Suggest the best possible way to provide wireless connectivity between Surajpur
Center and Raipur Center. (1)
32. (a) Write the output of the code given below: (2)
p,q=8, [8]
def sum(r,s=5):
p=r+s
q=[r,s]
print(p, q, sep='@')
sum(3,4)
print(p, q, sep='@')
7
(b) The code given below accepts the increments the value of Clas by 1 foreach
student. The structure of a record of table Student is: (3)
RollNo – integer; Name – string; Clas – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root, Password is abc
The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
(b) The code given below reads records from the table named Vehicle and displays only
those records which have model later than 2010. The structure of a record of table
Vehicle is:
V_ID – integer; Name – string; Model – integer; Price – integer
8
import mysql.connector as mysql
def display():
con1=mysql.connect(host="localhost",user="root", password="abc",
database="Transport")
#Statement 1
print("Students with marks greater than 75 are : ")
q="Select * from vehicle where model>2010"
#Statement 2
data= #Statement 3
for rec in data:
print(rec)
33. (a) What one advantage and one disadvantage of using a binary file for permanent (5)
storage?
(b) Write a Program in Python that defines and calls the following user defined
functions:
(i) ADD() – To accept and add data of an item to a CSV file ‘events.csv’. Each
record consists of Event_id, Description, Venue, Guests, and Cost.
(ii) COUNTR() – To read the data from the file events.csv, calculate and display the
average number of guests and average cost.
OR
(a) Give any one point of difference between a binary file and a text file.
(b) Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an item to a binary file ‘events.dat’. Each
record of the file is a list [Event_id, Description, Venue, Guests, Cost].
Event_Id, Description, and venue are of str type, Guests and Cost are of
int type.
(ii) COUNTR() – To read the data from the file events.dat, calculate and display the
average number of guests and average cost.
SECTION E
34. Ifrah is a class XII student. She has created her Computer Science project in Python and (4)
saved the file with the name 'CarAgency.py'. Her code contains many blank lines.
Now she has written another Python script to remove all the bank lines from
'CarAgency.py' and to precede each line with a line number. For example, if
CarAgency.py originally contains:
import random, pickle
cars=[]
def estimate():
cost=0
Then after the program execution, the file 'CarAgency.py' should contain:
1. import random, pickle
2. cars=[]
3. def estimate():
4. cost=0
9
As a Python expert, help her to complete the following code (by completing
statements 1, 2, 3, and 4) based on the requirement given above.
(i) Statement-1 to import required functions.
(ii) Statement-2 to open temp.py in suitable mode.
(iii) Statement-3 to write line into temp.py
(iv) To delete CarAgency.py
from os #Statement 1
f1=open("CarAgency.py")
f2=open( , ) #Statement 2
i=1
for line in f1:
line=line.rstrip()
if len(line)>0:
line=str(i)+'.\t'+line+'\n'
i+=1
#Statement 3
f1.close()
f2.close()
#Statement 4
rename("temp.py","CarAgency.py")
35. Raghav has been assigned the task to create a database, named Projects. Healso has to (4)
create following two tables in the database:
(i) Which table should he create first – Projects or Employee? Justify your answer.
(ii) What will be the degree of the Cartesian product of these two tables?
(iii) Write the SQL statement to create the table Employee.
(iv) Write the SQL statement to add a column Gender of type char(1) to the table
Employee, assuming that table Employee has already been created.
----------XXXXXXXXXX----------
10