3 Sample Paper QP
3 Sample Paper QP
ु ग्राम संभाग
KENDRIYA VIDYALAYA SANGATHAN GURUGRAM REGION
कक्षा- XII Class-XII
2023-24
Max Marks: 70
Subject: COMPUTER SCIENCE Time: 3 HOURS
General Instructions:
1. This question paper contains five sections, Section 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 Q35
against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION-A
1 Find the invalid identifier from the following 1
a) _D b) D1 c) 1D d) D_
3 Which among the following list of operators has the highest precedence? 1
*, /, +, -, %, **
a) (5,5) b) (5) c) 10 d) 5
10 CAT-6 is type of Co-axial cable. (True/False) 1
11 Which of the following is not a legal constraint for a CREATE TABLE command? 1
a) Primary Key b) Foreign Key c) Unique d) Distinct
12 What is the best data type definition for MySQL when a field is alphanumeric and 1
has a fixed length?
a) VARCHAR b) CHAR c) INT d) DECIMAL
13 SQL is a programming language (True/False) 1
14 Write name of command for selection of a particular database. 1
15 Where and having clauses can be used interchangeably in SELECT queries. 1
(True/False)
16 The language used in application programs to request data from the DBMS is 1
referred to as _______________
a) DML b) DDL c) TCL d) None of the above
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 4
(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):- Everything in python is considered as objects and memory is 1
allocated dynamically .
Reasoning (R):- Heap and Stack is maintained during memory allocation
18 Assertion (A):- Text files are processed very fast in comparison to binary files. 1
Reasoning (R):-Binary files contain data in true binary format ( machine code )
SECTION-B
19 Evaluate the following expressions: 2
a) 5-1*27/3**2//2
b) 101 > 201 or 20 < 12 and not 25 > 25
20 What is URL and domain name. How both are related. 2
OR
How web server and web browser communicate ? Which one is known as client?
21 Rewrite the following code in Python after removing all syntax error(s). Underline 2
each correction done in the code.
x=int(“Enter value for x:”))
for y in range[0,11]:
if x==y:
print x+y
else:
Print(x-y)
22 Write an sql command ( query ) to remove primary key “ROLLNO” from relation 2
“STUDENTS”
23 (a) Write the full forms of the following: 2
(i) POP3 (ii) NSFNET
(b) What is the use of Gateway?
24 Find and write the output of the following Python code: 2
def Output(str1):
str2=''
index=len(str1)
while index>0:
str2+=str1[index-1]
index=index-1
return str2
print(Output('GURGAON'))
OR
def Output(S1,S2):
if (S1+S2)%2==0:
return S1+S2
else:
return S1-S2
LT= [10,15,20,12]
A=3
for I in LT:
print(Output(I,LT[A]),'#', end=' ')
A=A-1
25 In a relational data model a relation is having 10 tuples and 6 attributes. Find its 2
degree and cardinality.
or
Explain the difference between equi-join and natural join.
SECTION-C
26 Give output for following SQL queries as per given tables- 3
Table : ITEM
Table : CUSTOMER
C_ID CustomerName City I_ID
01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sharma Delhi LC03
16 K Agarwal Banglore PC01
Bhiwadi : 3
Rewari : 2
OR
Write a function COUNTCHAR() to count all special characters including blank
spaces from a file “module.txt” and display it.
For example if file module.txt contains-
Table :FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
Block A 25
Block B 50
Block C 125
Block D 10
Center to center distances Number of Computers
Black A to Block B 50 m
Block B to Block C 150
m
Block C to Block D 25 m
Block A to Block D 170
m
Block B to Block D 125
m
Block A to Block C 90 m
(v) The organization is planning to link its front office situated in a far city in a hilly
region where cable connection is not feasible, suggest a way to connect it with
reasonably high speed?
32
(a) Find and write the output of the following python code: 2
def FUN(P ,Q=50):
P=P+Q
Q=P-Q
print(P,"#",Q)
return (P)
R=300
S=200
R=FUN(R,S)
S=FUN(S)
(b) Fill all the given blanks for the following python code with sql interface so that 3
contents of table student can be read and displayed using python program.
(i) INSERT() – To accept and add data of a teacher to a CSV file ‘data.csv’. Each
record consists of a list with field elements as tpid, tname and tmobile to store
teacher id, teacher name and teacher mobile no respectively.
(ii) COUNTR() – To count the number of records present in the CSV file named
‘data.csv’.
OR
What do you mean by file modes? Write a Program in Python that defines and
calls the following user defined functions:
(i) INSERT() – To accept and add data of movies to a CSV file ‘moviedata.csv’. Each
record consists of a list with field elements as Mid, Mname and Mtprice to store
movie id, movie name and movie ticket price respectively.
(ii) FIND()- To display the records of the movies whose ticket price is more than
200.
SECTION E
34 Write SQL queries for the question no (i), (ii) and output of (iii) 4
TABLE : TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06
(I) Identify the most appropriate column, which can be considered as Primary key.
(II) If one column is 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 TRNO- T006, ANO- 102,
AMOUNT-1600, TYPE-Deposit, DOT- 2018-04-26.
b. Increase the AMOUNT of T001 by 500.
OR (Option for part iii only)
Write the statements to:
a. Delete the record of Deposit Transactions.
b. Add a column interest in the table with datatype as integer
35 Mahendra is a Python programmer. He has written a code and created a binary file 4
collection.dat with product id, product name and product price. The file contains
10 records. He now has to update a record based on the product id entered by the
user and update the price. The updated record is then to be written in the file
file2.dat. The records which are not to be updated also have to be written to the
file file2.dat. If the product id is not found, an appropriate message should to be
displayed. As a Python expert, help him to complete the following code based on
the requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("collection.dat","rb")
fout=open("_____________") #Statement 2
found=False
pid=int(input("Enter product id to update price:: "))
while True:
try: rec=______________ #Statement 3
if rec["PID"]==pid:
found=True
rec["PRICE"]=int(input("Enter new price:: "))
pickle.____________ #Statement 4
else: pickle.dump(rec,fout)
except:
break
if found==True:
print("The price of product id ",pid," has been updated.")
else:
print("No product with such id is found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a temporary file named file2.dat.
(Statement 2)
(iii) Which statement should Mahendra fill in Statement 3 to read the data from
the binary file, collectionb.dat
(iv) In Statement 4 Write the statement for updating data in the file, file2.dat
------------