12 CS ERNAKULAM-SAMPLE QUESTION PAPERS-22-23-1

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

KENDRIYA VIDYALAYA SANGHATHAN – ERNAKULAM REGION 8. Which of the following is not a DDL command?

1
SAMPLE PAPER-1(SOLVED) – COMPUTER SCIENCE (083) a) UPDATE b) TRUNCATE c) ALTER d) None of the Mentioned

MAX MARKS: 70 TOTAL TIME : 3 hrs 9. To include the use of functions which are present in the random library, we 1
must use the option:
General Instructions: a) import random
1.This question paper contains five sections, Section A to E. b) random.h
c) import.random
2. All questions are compulsory.
d) random.random
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 10. How many values can be returned by a function in python? 1
5. Section C has 05 Short Answer type questions carrying 03 marks each. a) 0 b) 1 c) more than one d) 2
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 11. print (id(x)) will print_______. 1
c only. 1. Value of x 2. Datatype of x 3. Size of x 4. Memory address of x
8. All programming questions are to be answered using Python Language only.
Part A 12. Which of the following command is used to change the VALUES OF rows that 1
Section 1 [18 marks] (1x18)( attempt any 18) already exist in a table?
1. Insert. 2. Union. 3. Update. 4. Select
1. Which of the following symbols are used for comments in Python? 1
13. Give the output: my_data = (1, 2, "Kevin", 8.9) print (my_data[-3]) 1
(A) // (B) & (C) /**/ (D) # 1. 8.9 2. “Kevin”. 3. 1 4. 2
2. Suppose str=”computer science with python” .What will be the output of 1
print(type(str)) 14. Suppose list1 is [1, 3, 2], What is list1 * 2 ? 1
(a)int (b) bool (c) string (d)str a) [2, 6, 4]. b) [1, 3, 2, 1, 3]. c) [1, 3, 2, 1, 3, 2] . d) [1, 3, 2, 3, 2, 1]
3. The RDBMS terminology for a row is 1
(a) Tuple (b) relation (c) attribute (d) degree 15. The readlines() method returns 1
a) str b) a list of lines c) a list of single characters d) a list of
4. ____________Spans over less than a Kilometer 1 integers
a)MAN b)LAN c)WAN d)All of the above
16 To write data into CSV from python console, which of the following function is 1
correct?
5. The act which governs the cyber transactions in India is_______________ 1
a)IT act 2000 b)IT act 2008 c)IT act 2003 d)None of these a) csv.write(file) b) csv.writer(file)
c) csv.Write(file) d) csv.writerow()
6. A network device used to divide a single computer network into various sub- 1
networks . i)router ii)switch ii)hub iv)R Statement (A) : A function can perform certain functionality 1
17 Statement (B) : A function must return a result value
7. With SQL, how do you select all the records from a table named “Persons” 1
a) Statement A is correct
where the value of the column “FirstName” ends with an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’ b) Statement B is correct
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) Statement A is correct but Statement B is not correct
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’. d) Both are incorrect

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 223 KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 224
18 Ms. Suman is working on a binary file and wants to write data from a list to a 1 25 In the table Loan below 2
binary file. Consider list object as l1, binary file suman_list.dat, and file object as (a) Identify the candidate key(s) from the table Garment.
f. Which of the following can be the correct statement for her? (b) What is the cardinality and degree of the table?
a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
b) f = open(‘sum_list’,’rb’); l1=pickle.dump(f)
c) f = open(‘sum_list’,’wb’); pickle.load(l1,f)
d) f = open(‘sum_list’,’rb’); l1=pickle.load(f)

Section B [14 marks] [2x7=14]


Answer All questions
Section C [15 Marks] [3x5]
19 Evaluate the following expressions: 2 Answer All questions
a) 6+7*4+2**3//5-8
26 Vedika has created a dictionary containing names and marks as key-value pairs 3
b) 8<5 or no 19<=20 and 11<4 of 5 students. Write a program, with separate user-defined functions to perform
the following operations:
20 Write down the fullform of : 2
POP b) TCP/IP c) WWW d) HTTPS Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
21 Differentiate between Candidate Key and Primary Key in the context Relational 2 Pop and display the content of the stack.
Database Mode The dictionary should be as follows:

22 What will be the output of the following code? 2 d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
a=[1,2,3,4]
s=0 Then the output will be: Umesh Vishal Ishika
for a[-1] in a:
print(a[-1])
s+=a[-1] 27. A department is considering to maintain their worker data using SQL to store the 3
data. As a database administer, Karan has decided that :
print(‘sum=’,s)
Name of the database - Department
23 Difference between ALTER & UPDATE commands. 2
Name of the table - WORKER
24 Smridh has recently changed his school so he is not aware of the people, but 2
someone is posting negative , demeaning comments on his social media profile. The attributes of WORKER are as follows:
He is also getting repeated mails from unknown people. Every time he goes WORKER_ID - character of size 3
online, he finds someone chasing him online. FIRST_NAME – character of size 10
LAST_NAME– character of size 10
i. Smridh is a victim of ………… SALARY - numeric
JOINING_DATE – Date
ii. The act of fraudulently acquiring someone’s personal and private information,
DEPARTMENT – character of size 10
such as online account names, login information and passwords is called as
……………
I)Identify the attribute best suitable to be declared as a primary key
II) Karan wants to increase the size of the FIRST_NAME column from 10 to 20

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 225 KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 226
characters. Write an appropriate query to change the size. b )Display a report, listing NAME , STIPEND , SUBJCT and amount of stipend
III) Karan wants to remove all the data from table WORKER from the database received in a year assuming that the STIPEND is paid every month.
Department. C.) Give the output of the following SQL statements based on table GRADUATE :
Which command will he use from the following: (i) Select MIN(AVERAGE ) from GRADUATE where SUBJECT=”PHYSICS”;
(ii)Select SUM(STIPEND) from GRADUATE where DIV=1;
i) DELETE FROM WORKER;
ii) DROP TABLE WORKER; 30 A) Write a function countmy() in Python to read the text file "DATA.TXT" and 3
iii) DROP DATABASE Department; count the number of times "my" occurs in the file.
iv) DELETE * FROM WORKER For example, if the file "DATA.TXT" contains "This is my website. I have displayed
my preferences in the CHOICE section." - the countmy() function should display
28. Ashok Kumar of class 12 is writing a program to create a CSV file “cust.csv” with 3 the output as: "my occurs 2 times"Or
custid, custname and mobile no and search custname and delete the record. He Write a method/function DISPLAYWORDS() in python to read lines from a text
has written the following code. As a programmer, help him to successfully file STORY.TXT, and display those words, which are less than 4 characters.
execute the given task.
import _______ # LINE1 Or
record = list()
custname= input("Please enter a customer name to delete:") A) Write a method/function DISPLAYWORDS() in python to read lines
with open('cust.csv', 'r') as f: from a text file STORY.TXT,and display those words, which are less than 4
data = csv._______(f) # LINE2 characters
for row in data:
record.append(row) Section D [15 Marks]
for field in row: [5x3]
if field == custname:
record.____(row) #LINE3 31. Indian School, in Mumbai is starting up the network between its different wings. 5
with open('cust.csv', 'w') as f: There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as
writer = csv.writer(f) shown below:
writer.writerows(record

A) Name the module he should import in Line 1.


b) Write a code to read the fields (column heading) once from fields list in
Line2.
(c) Write a code to delete the row from row list in Line3.

29. Write SQL commands for(a) to (b) and write the outputs for (C) on the basis of 2+1
table GRADUATE The distance between various buildings is as follows

1. Suggest the cable layout of connections between the buildings. (1)


2. Suggest the most suitable place (i.e., building) to house the server of this
school, provide a suitable reason. (1)
a) List the names of those students who obtained DIV 1 sorted by NAME . 3. Suggest the placement of the following devices with justification. (2)

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 227 KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 228
a. Repeater b.Hub/Switch 33 A. Considering the following definition of dictionary MULTIPLEX, write a method 5
in python to search and display all the content in a pickled file CINEMA.DAT,
4. The organisation also has inquiry office in another city about 50-60 km where MTYPE key of the dictionary is matching with the value "Comedy".
away in hilly region. Suggest the suitable transmission media to interconnect
to school and inquiry office out of the following : (1) MULTIPLEX = {'MNO': _____, 'MNAME": _____, 'MTYPE': _____}

a) Fiber optic cable Or


b) Microwave Following is the structure of each record in a data file named "phonebook.DAT".
c) Radiowave {“name”: value, "phone": value}
Write a program to edit the phone number of “Arvind” infile “phonebook.dat”. If
there is no record for “Arvind”, report error.
32. Give Output of : 5
(2+3)

def Change (P, Q = 30) : 34 Write SQL commands for the queries (i) to (iii) and output for (iv) & (vii) based 4
P=P+Q on a
Q=P-Q
print (P,"@",Q)
return P
R =150
S= 100
R=Change(R, S)
print(R,"@",S)
S=Change (S)

1. The books table of test database contains the records shown below:-

Title ISBN
Die to Live 78127873915
table COMPANY and CUSTOMER
Again? 23686286243
Ushakaal 12678987036 I) Identify the most appropriate Primary key for Tables Company and Customer.
Ushakiran 42568987036
What will be the output produced by following code: Ii) To display those company name which are having prcze less than 30000.
import mysql.connector as sqltor.
iii a.To increase the price by 1000 for those customer whose name starts with S?
conn = sqltor.connect (host = "localhost", user = "learner", passwd = "fast",
database = "test") b) What is the cardinality and degree of table customer?
cursor = conn.cursor()
cursor.execute("SELECT * FROM books") Or
row = cursor.fetchone()
while row is not None: Iii)a) Delete the records from table customer whose name has KUMAR.
print (row)
row = cursor.fetchone() B. Insert a new record in table COmpany where CID : 777, Name : APPLE City
KOCHI and PRODUCTNAME is LAPTOP

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 229 KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 230
35 Aradhana is creating a binary file student.dat that has structure 4
(rollno,name,class,percentage). She wrote a program to updating a record in
the file requires roll number to be fetched from the user whose name is to be
updated. She has few doubts in the code. Help her to complete the task. She
uses intermediate file for working temp.dat
Import______ #STATEMENT 1
import os
f1 = open(‘student.dat','rb')
f2=open(“temp.dat”,”______”) #Statement2
r=int(input(“enter rollno which you want to search”))
try:
while True:
e = pickle.load(f1)
if e[0]==r:
e[1]=input(“enter name”)
pickle.dump(____) #Statement3
else:
pickle.dump(e,f2)
except:
f1.close()
f2.close()
os.remove(“student.dat”)
os._______(“temp.dat”,”student,dat”) #Statement4

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


(ii) Write the correct statement required to open a temporary file named
temp.dat. (Statement 2)
(iii) ) Which statement should Aradhana fill in Statement 3 to write the data
to the binary filedat
(iv) Statement 4 to write the rename temp.dat to student.dat?

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022-23 231

You might also like