Computer Science PRE BOARD QP 2022 23

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Code No.

91

COMMON PRE-BOARD EXAMINATIONS - 2023


COMPUTER SCIENCE (083)

Time Allowed: 3 hours CLASS: XII Maximum Marks: 70


General Instructions:
1. This question paper contains five sections, Sections 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. One internal choice is given in Q34
against part (iii) only.
8. All programming questions are to be answered using Python Language only.

SECTION - A
1. Which of the following statements is not correct? 1
a) An element in a dictionary is a combination of key-value pair.
b) A tuple is a mutable data type.
c) We can repeat a key in a dictionary.
d) clear() function is used to delete the dictionary.

(i) a, b, c (ii) b, c, d (iii) d, c, a (iv) a, b, c, d

2. Which of the following statements converts a tuple into a list? 1

a) len(string) b) list(tuple) c) tup(list) d) dict(string)

3. Which of the following is a valid relational operator in Python? 1

a) + b) ** c) > d) and

4. 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)

1 / 11
5. What is the output of the following code? 1
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)

a) [‘AB’, ‘CD’].
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
d) no output

6. Suppose the content of a text file “notes.txt” is “The.way to get started is to quit 1
talking and begin doing”, What will be the output of the following Python code?

F=open(“notes.txt”)
F.seek(29)
S=F.read()
print(S)
(a) The.way to get started is to
(b) quit talking and begin doing
(c) The.way to get started is to quit talking and begin doing
(d) gniod nigeb dna gniklat tiuq ot si detrats teg ot yaw eht

7. Which command is used to change a database? 1


(a) Open (b) change (c) use (d) select
8. Choose the correct difference between primary and foreign keys. 1
(a) A table can have multiple primary keys and a single foreign key.
(b) A foreign key column data need not be present in the primary key column
of the primary table.
(c) A primary key cannot have null values while a foreign key can have nulls.
(d) A primary key can have duplicate data but a foreign key does not.

9. Sam has declared a tuple T in Python as follows: 1


T= (50, 60, 70)
Now, he wants to insert an element 80 after these three elements of T so that the
tuple may contain (50, 60, 70, 80). Which of the following statements should he
write to accomplish the above task?
(a) T=T+80 (b) T=T + (80)
(c) T=T+(80,) (d) sam cannot insert 80 into the tuple since tuples are
immutable
10. Command to remove all rows from table student is:- 1
(a) drop table student;
(b) drop from student;
(c) remove from student;
(d) delete from student;

2 / 11
11. Which of the following commands can be used to read “n” number of characters 1
from a file using the file object <File>
(a) File.read(n) (b) N=file.read()
(c) File.radline(n) (d) File.readlines()

12. Fill in the blanks 1


_________________command is used to modify the structure of a table

(a) Delete (b) update (c) Alter table (d)Modify

13. Fill in the blank: 1


MAC address is a _______________long.
(a) 16 bit (b) 32 bit (c) 48 bit (d) 64 bit

14. Suppose the content of “rhymes.txt” is Good Morning Madam. What will be the 1
output of the Python code?

F=open(“rhymes.txt”)
L=F.read().split()
for i in L:
if i.lower()==i[: : -1].lower():
print(i)

(a) Good (b) Morning


(c) Madam (d)Error

15. Which operator defines a range of values that a column value must fall within? 1
(a) Between (b) like (c) IN (d) ISNULL
16. In which of the following case a DML command is not executed? 1
a) When a new record is added.
b) When an existing record is modified.
c) When an existing attribute is modified.
d) When records are deleted.
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): -The readline() method reads one complete line from a text file. 1
Reasoning (R): - The readline() method reads one complete line at a time along
with a newline(\n). It can also be used to read a specified number (n) of bytes of
data from a file but maximum upto newline(\n) character.

3 / 11
18. Assertion (A): - A stack is a linear data structure, that stores elements in First in 1
First out order.
Reasoning (R): - New element is added at one end and the element is removed
from that end only.

SECTION – B
19. Nitish has written a code in python to display all prime numbers between m and n, 2
where m and n have to be input from the user. His code is having errors. Rewrite
the correct code and underline the corrections made.

m=int(input(‘Enter the first number”))


n=int(input(enter the second number))
for i in range(m, n)
if i>1:
for j in range(2,i):
if i % j = 0:
break
Else:
print(num)

20. What is the difference between HTML and XML? 2

OR

Write the difference between a server-side script and a client-side script.

21. (a) Given a Python string declaration: 1


str1 = "coronavirus disease"
strg = str1.rstrip("sea")
print(strg)

(b) Evaluate the following expression: - 1


6*3+4**2//5-8
22. What are aggregate functions in SQL? 2
23. (a) Write the full forms of the following: 2
(i) GPRS (ii) POP

(b) Out of the following, which is the fastest wired medium of communication?
Coaxial cable, ethernet cable, infrared, microwave, Optical fibre.

4 / 11
24. Find and write the output of the following code: 2

Numbers = [9, 18, 27, 36]


for Num in Numbers:
for N in range(1,Num % 8):
print(N, "#", end="")
print()

OR

data = ["P", 20, "R", 10, "5", 30]


Times=0
Alpha=""
Add=0
for c in range(1,6,2):
Times=Times+c
Alpha=Alpha + data[c-1] + "S"
Add = Add + data[c]
print(Times, Add, Alpha)

25. Differentiate between delete and drop commands in MySQL. 2

OR

Categorize the following commands as DDL or DML:


CREATE, INSERT, UPDATE, DROP

SECTION - C
26. Consider the following tables – Student and Stream

Table- Student

Admno Name Class Sec Streamid


1101 Naveen XII A 10
1102 Chetna XII A 10
1103 Imran XI C 30
1104 Shailendra XII B 20
1105 Tejas XI A 10
1106 Zoya XI B 20
1107 Swati XII D 40

5 / 11
Table-Stream
Streamid Sname
10 Medical
20 NonMedical
30 Commerce
40 Humanties
(a) What will be the output for the following statement? 1

Select * from student natural join stream;

(b) Write the output of the queries (i) to (iv) based on the table student: 2

i. Select admno, name from student where class= “XII”;

ii. Select distinct(streamid) from student;

iii. Select count(*) from student where class = “XII” and streamed = 10;

iv. Select sec, count(sec) from student group by sec;

27. Write a user-defined function to display the total number of words present in the 3
file “quotes.txt”
OR
Write a function countmy() in python to read the text file “data.txt” and count the
number of times “my” occurs in the file.

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Handsets 2
and customer given below:
Table: Handsets
Setcode Setname Touchscreen Phonecost
N1 Nokia 2G N 5000
N2 Nokia 2G Y 8000
B1 Blackberry N 14000

Table: Customer
Custno Setno Custaddress
1 N2 Delhi
2 B1 Mumbai
3 N2 Mumbai
4 N1 Kolkata
5 B1 Delhi

6 / 11
i. SELECT CUSTNO, CUSTADDRESS, SETNAME FROM HANDSETS H, CUSTOMER C
WHERE H.SETCODE = C.SETNO;

ii. SELECT SUM(PHONECOST) FROM HANDSETS GROUP BY TOUCHSCREEN;

iii. SELECT * FROM CUSTOMER WHERE SETNO IN ('N1','N2');

iv. UPDATE HANDSETS SET PHONECOST=PHONECOST+PHONECOST * 0.1;


(b) Write command to add a new column GST in the handsets table 1

29. Write a Python program to input 10 numbers from the user and store it in a list. 3
Add all the elements present at the odd indices of the list.

30. Write a function in Python push(Arr), where Arr is a list of numbers. From this list 3
push all numbers multiple of 6 into a stack implemented by using a list. Display the
stack if it has at least one element, otherwise display an appropriate error
message.

OR
Write a function pop(Arr) in Python where Arr is a stack implemented by a list of
numbers. The function returns the value deleted from the stack.

SECTION - D

31. The company Mega enterprises has 4 wings of buildings as shown in the diagram. 5

W1 W2

W3 W4

Computers in each wing are networked but the wings are not networked. The
company has now decided to connect the wings also.
Center to center distances between Number of computers in each of
various buildings the wings
W3 to W1- 50m
W1 to W2- 60m W1-150
W2 to W4- 25m W2-15
W4 to W3- 170m W3-15
W3 TO W2- 125m W4-24
W1 to W4- 90m

7 / 11
(a) Suggest the most suitable cable layout for the above connections.
(b) Suggest the most appropriate topology of the connection between the wings.
(c) The company wants internet accessibility in all the wings. Suggest a suitable
technology.
(d) Suggest the placement of the following devices with justification if the
company wants minimized network traffic.
(i) Repeater (ii) Hub or switch
(e) The company is planning to link its head office situated in New Delhi with the
offices in the hilly areas. Suggest a way to connect it economically.

32 (a) Write the output of the given program:- 2


def display(n):
sum=5
i=1
while i <= n:
sum += i
i += 5
sum=sum-2
print(“value=”, sum, “ i=”, i)
x=30
display(x)

(b) SS Public School is managing student data in ‘student’ table in school 3


database. Given below is a Python code that connects to database school and
retrieves all the records and displays total number of students. Write the
following missing statements to complete the code:

Statement 1 – Write a command to form the cursor object.


Statement 2 – Write a command to execute the query that extracts records.
Statement 3 – Write a command to read the complete result of the query into
the object named record, from the table student in the database.

import mysql.connector as sqltor


con=sqltor.connect(host= “localhost”, user= “root”, password = “ ” database=
“school”)
cursor = _____________________ #statement 1
cursor.execute (_____________________) #statement 2
record =______________________ #statement 3
count=0
for x in record:
count +=1
print(x)
print(“Total number of records are:”,count)

8 / 11
OR
(a) Predict the output of the following:-
Find the output of the following code:
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i] //=5
if M[i]%3 == 0:
M[i]//=3
L = [25,8,75,12]
ChangeVal(L,4)
for i in L:
print(i, end = "#")

(b) The code given below updates the records of employees by increasing salary
by ₹ 1000 for all those employees who are getting less than 80000. The table
name is emp. Write the following missing statements to complete the code:

Statement 1 – Write a command to form the cursor object.


Statement 2 – Write command to execute the query that updates the
record.
Statement 3- Write a command to save data permanently in the database.
import mysql.connector as sqltor
db=mysql.connect(host= “localhost”, user= “root”, password= “ ”, database =
“company”)
cursor=______________#Statement 1
sql= “update EMP set salary=salary +1000 where salary < 80000;”
___________________ #Statement 2
____________________#Statement 3
db.close ()

33. When do you think binary files should be preferred over text files? 5
Create a CSV file “Groceries” to store information on different items existing in a
shop. The information is to be stored with respect to each item code, name, price,
and qty. Write a program to accept the data from the user and store it
permanently in a CSV file and also display the stored data.

OR
Genesis Infotech plans to develop a computerized system for payroll processing of
all its employees for storing salary details. Develop a Python program which stores
data in “employee.csv”, calculates and displays total salary remitted to its
employee. The details to be stored are [empno, name, salary]

9 / 11
SECTION - E
34 Krishna, working as a computer professional in a hospital, creates a table OPD to
store records of patients registered in the OPD section. A sample of the records is
given below:
Table: OPD
RegNo Name Age Department Dateof_Reg Charges Gender RoomNo
R0123 Arpita 62 Gen. 2022-01-21 500 M 10
Physician
R0124 Jai 22 ENT 2022-10-12 300 M 15
R0125 Kamal 32 Orthopaedic 2022-02-19 500 M 11

R0126 Arun 12 Paediatrician 2022-07-11 500 M 12

R0127 Neha 30 ENT 2022-01-12 300 F 15

R0128 Neetu 16 ENT 2022-09-24 300 F 15

R0129 Ankit 29 Cardiology 2022-02-20 800 F 20

Based on the data given above, answer the following questions:

(i) If the table “OPD” is to be linked with another table “Registration” in the same 1
database named “Hospital”, then identify the most appropriate column which can
be used as a Foreign key in the “Registration” table.
(ii) What is the cardinality and degree of the given table? 1
(iii) Write the statements to:
(a) Insert the following record into the table: 1
RegNo–R130, Name–Naman, Age–30, Department–ENT, Dateof_Reg–
2022-10-10, Charges–700, Gender–M, Roomno-12
(b) Increase the OPD Charges of the ENT department by ` 200. 1

OR (Option for part iii only)

(iii) Write the statements to:


(a) Delete the column RoomNo from the table OPD.
(b) Add a new column Panel_Discount in the table with datatype as Varchar
with 50 characters.

35. You are a student in CBSE school. Teacher has given a task to write a python code
to create a binary file called school.dat containing student information(in list data
type)- student number, name, marks(out of 100) of each student. This binary file
operation is performed with the help of user defined function addrecord(). You
need to write the code in the missing statement.

import __________ #statement 1


def addrecord():

10 / 11
student=[]
f=open(______________) #statement 2
ch=’y’
while ch== ‘y’:
stno= int(input(“Enter student number”))
sname=input(“Enter name”)
marks=int(input(“Enter marks”))
s=[stno,sname,marks]
student.________(s) #statement 3
ch=input(“want to add more records(y/n)”)
pickle.___________ #statement 4
f.close()

a. Which module should be imported in the program? (Statement 1) 1


b. Write the correct statement to open the file (statement 2) 1
c. Write the list method to add data to the list record (statement 3) 1
d. Write the code to write the data into the binary file in (statement 4) 1

********************************************************************************

11 / 11

You might also like