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

I.

c
II. c
III. a load(f)
IV. d. rec[0]==1

KENDRIYA VIDYALAYA SANGATHAN-CHENNAI REGION


CLASS: XII Session 2022-2023
COMPUTER SCIENCE (083)
SAMPLE QUESTION PAPER - IV
Max. Marks: 70 Time Allowed: 3 Hrs.
General Instructions:
1.
This question paper contains five sections, Section A to E.
2.
All questions are compulsory.
3.
Section A have 18 question 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 Which of the following is not a valid identifier in Python? 1
a)KV2 b) _main c) Hello_Dear1 d) 7 Sisters
2 A variable created or defined in a function body is known as… 1
a)local b) global c) built-in d) instance
3 Suppose list1 = [0.5 * x for x in range(0,4)], list1 is 1
a) [0, 1, 2, 3] b) [0, 1, 2, 3, 4]
c) [0.0, 0.5, 1.0, 1.5] d) [0.0, 0.5, 1.0, 1.5, 2.0]
4 Which statement is not correct 1
a)The statement x = x + 10 is a valid statement b)List slice is a list itself.
c)Lists are immutable while strings are mutable.
d)Lists and strings in pythons support two way indexing.
5 What will be the output of following code snippet: 1
msg = “Hello Friends”
msg [ : : -1]

293 | P a g e
a)Hello b) Hello Friend c) 'sdneirF olleH' d) Friend
6 Which of the following function is used to write data in binary mode? 1
a) write ( ) b) output ( ) c) dump ( ) d) send ( )
7 Suppose a tuple T1 is declared as T1 = (10, 20, 30, 40, 50) which of the following is 1
incorrect?
a)print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T))
8 What will be output of following: 1
d = {1 : “SUM”, 2 : “DIFF”, 3 : “PROD”}
for i in d:
print (i)
a)1 b) SUM c) 1 d) 3
2 DIFF SUM SUM
3 PROD 2 3
DIFF DIFF
3 3
PROD PROD

9 What will be output of following code: 1


X = 50
def funct(X):
X=2
funct (X)
print(„X is now: „, X)
a) X is now: 50 b) X is now: 2 c) Error d) None of the above
10 To read the next line from the file object fob, we can use: 1
a)fob.read(2) b) fob.read( ) c) fob.readline( ) d) fob.readlines( )
11 TCP/IP stands for 1
a) Transmission Communication Protocol / Internet Protocol
b) Transmission Control Protocol / Internet Protocol
c) Transport Control Protocol / Interwork Protocol
d) Transport Control Protocol / Internet Protocol
12 An attack that encrypts files in a computer and only gets decrypted after paying 1
money to the attacker..
a) Botnet b) Trojan c) Ransomware d) Spam
13 Which is known as range operator in MySQL. 1
a) IN b) BETWEEN c) IS d) DISTINCT
14 If column “salary” of table “EMP” contains the dataset {10000, 15000, 25000, 10000, 1
25000}, what will be the output of following SQL statement?
SELECT SUM(DISTINCT SALARY) FROM EMP;
a) 75000 b) 25000 c) 10000 d) 50000
15 Which of the following functions is used to find the largest value from the given data 1
294 | P a g e
in MySQL?
a) MAX ( ) b) MAXIMUM ( ) c) LARGEST ( ) d) BIG ( )
16 Name the clause used in query to place the condition on groups in MySQL? 1
Q17 and 18 are Assertion and Reasoning based questions.Mark the correct choice as
a)A is true R is false
b) A is false and R is true
c) Both A and R are correct and R is correct explanation of A
d) Both A and R are correct and R is not correct explanation of A

1 Assertion : The number of addresses used in IPv6 addressing method is 128 1


7
Reason : IPv6 address is a 128 bit unique address
1 Assertion : Delete command is used to remove rows or records from table. 1
8 Reason : This command is used to remove records along with structure of the table from
database
SECTION B
1 Rewrite the following code after removing the syntactical error(if any).Underline each 2
9 correction:
X=input("Enter a Number")
If x % 2 =0:
for i range (2*x):
print i
loop else:
print "#"
2 Write two points of difference between Client side script and Server side script 2
0 OR
Write two advantages of Twisted pair cable.
2 Write the output of the following python code: 2
1 def func(b):
global x
print ('Global x=',x)
y=x+b
x=7
z=x-b
print ('Local x=' ,x)
print ('y=' ,y)
print ('z=' ,z)
x=5
func(10)
2 What is the purpose of BETWEEN clause? 2
2
2 a) What do the following top level domains signify? (i) .com (ii) .org 2
3 b)What is the use of VoIP?
2 Write the output of the following python code: 2
295 | P a g e
4 x=7
def new():
x=70
print("x=",x)
print("x=",x)
new()
print("x=",x)
OR
Write the output of the following python code:
Numbers =[9,18,27,36]
for num in Numbers:
for N in range(1,num%8):
print(N,"$",end="")
print()
2 Differentiate between equi join and cross join function in SQL with a example 2
5 OR
Categorize the folowing commands as DML or TCL
COMMIT ,UPDATE , DELETE ,SAVE POINT
SECTION –C
2 a)Observe the table ‘Club’ given below:Table: Club 3
6 Member_id Member_name Address Age Fee
M001 Sujith New delhi 20 2000
M002 Nisha Trichy 18 3500
M003 Tarun Chennai 22 2100
M004 Arjun Coimbatore 19 3200
What is the cardinality and Degree of above table
b) Write the queries of the i to iv based on the table: Shop given below
Table: Shop
Code Iname Qty Price Company
101 Digital Pad 120 11000 Xenita
105 Pen Drive 64 GB 500 7000 Hp
103 LED Screen 40' 50 25000 Samsung
104 Car GPS system 20 9000 Digiclick
i) To display the details of all the item in ascending order of item names
ii)To display item name and price of all those items whose price in range of 10000 to
30000
iii) To display max and min price of the table
iv)To display the total amount of digiclick company
2 Write a function show_word() in python to read the contant of a text file 'words.txt' and 3
7 display the entire content in upper case.example,if the file contain
"I love my country ,i am proud to be indian"
296 | P a g e
Then the function should display the output as:
I LOVE MY COUNTRY ,I AM PROUD TO BE INDIAN
OR
Write a function mycount() in python to read the text file 'file.txt' and count the number
of times "i" occurs in the file. example,if the file is 'file.txt'contains:
"I love my country ,i am proud to be indian"
The mycount()function should display the output as:
"i occurs 4 times".
2 a) Write the output of the SQL queries i to iv based on the relations CARHUB and 3
8 CUSTOMER given below:
Table :CARHUB
Vcode Vehicle Make Color Capacity Charges
Name
100 Innova Toyota White 7 15
102 SX4 Suzuki Blue 4 14
104 C Class Mercedes Red 4 35
105 A-star Suzuki White 3 14
108 Indigo Tata Silver 3 12
Table : CUSTOMER
CCode CName Vcode
1 Rajesh 101
2 Leela 108
3 John 105
4 Feroza shah 104
i)select vehiclename from carhub where color='white';
ii)select max,min from carhub;
iii)select count(*),make carhub;
iv)select cname,vehiclename,from customer,carhub where
customer.vcode=carhub.vcode;
b)Write the command to view all the tables in a database.
2 Write a python program using function to demonstrate random() with dictionary. 3
9 Should create the dictionary of 5 keys:valus random character as key and ASCII as its
value.
3 A list contains following records of students: 3
0 [Adm_no,SName,DOB,Mobile]
Write the following user defined function to perform given operations on the stack
named 'Admission':
i)PUSH() To insert an object containing admission number,student name and Mobile of
the students who's birth year is after 2008 to the stack. If stack holds more than 3 elements
show "stack is full"
ii) POP() To pop the object from the stack and display them in stack one by one.
For Example:
If the lists of students detail are :
["20221017","Guru","20-7-2008","9988779988"]
["20221018","Ragunath","06-8-2009","9977889988"]
["20221019","Jenifer","31-12-2007","9988996677"]
["20221020","Priya","21-10-2009","9966557864"]

297 | P a g e
The stack should contain
["20221017","Guru","9988779988"]
["20221018","Ragunath","9977889988"]
["20221020","Priya","9966557864"]

The output should contain


["20221017","Guru","9988779988"]
["20221018","Ragunath","9977889988"]
["20221020","Priya","9966557864"]
Stack is full
OR
Write a function in python, makepush(var) and makepop(var) ,to add a new variable and
delete a variable from list of variables description, considering them to act as push and pop
operations of the stack data structure.
SECTION-D
3 Uplifting Skills Hub India is a knowledge and skill community which has an aim to 5
1 uplift the standard of knowledge and skills in the society. It is planning to setup its training
centers in multiple towns and villages pan India with its head offices in the nearest cities.
They have created a model of their network with a city, a town and 3 villages as follows.
As a network consultant, you have to suggest the best network related solutions for their
issues/ problems raised in (a) to (d) keeping in mind the distances between various
locations and other given parameters.
Shortest distances between various locations:
Village 1 To B_Town 2 KM
Village 2 To B_Town 1.0
KM
Village 3 To B_Town 1.5
KM
Village 1 To Village 2 3.5
KM
Village 1 To Village 3 4.5
KM
Village 2 To Village 3 2.5
KM
A_city Head office to 25 KM
B_HUB
Number of Computers installed at various locations are as follows:
B_Town 120
Village 1 15
Village 1 10
Village 1 15
A_city Office 6
Note:
In Villages, there are community centers, in which one room has been given as training
center to this organization to install computers. The organization has got financial support
from the government and top IT companies.
(a) Suggest the most appropriate location of the SERVER in the B_HUB (out of the 4
locations), to get the best and effective connectivity. Justify your answer.
298 | P a g e
(b) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations within the B_HUB.
(c) Which hardware device will you suggest to connect all the computers within each
location of B_HUB?
(d) Which service/protocol will be most helpful to conduct live interactions of Experts
from Head Office and people at all locations of B_HUB
(e) Which type of network would be formed if B_HUB is connected to their A_city
3 a) What will be the output of the following python code? 5
2 v=25
def fun(ch):
v=50
print (v ,end=ch)
print(v, end="*")
fun("!")
print(v)
b)The code given below insert the record in the table employee:
Empno – integer
Name – string
Dept – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
❖ Username is host
❖ Password is root
❖ The table exists in a MYSQL database named company.
❖ The details (eno, Name, Dept and Salary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table employee.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="host", password="root",
database="company")
mycursor=_________________ #Statement 1
eno=int(input("Enter Employee Number :: "))
name=input("Enter name :: ")
dept=input("Enter department :: ")
salary=int(input("Enter salary :: "))
querry="insert into employee values({},'{}','{}',{})".format(eno,name,dept,salary)
______________________ #Statement 2
______________________ # Statement 3

299 | P a g e
print("Data Added successfully")
OR
a) Predict the output of the code given below:
str1=input ("Enter a string: ")
str2="aAeEiIoOuU"
v,c=0,0
for i in str1:
if i in str2:
v+=1
else:
c+=1
print ("The given string contains { } vowels and { } consonants".format(v,c))
b) The code given below reads the following record from the table named employee and
displays
only those records who have salary greater than 65000:
Empno – integer
Name – string
Dept – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
❖ Username is host
❖ Password is root
❖ The table exists in a MYSQL database named company.
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 employee whose salary
are greater
than 65000.
Statement 3- to read the complete result of the query (records whose salary are greater
than 65000) into the object named data, from the table employee in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="host",
password="root", database="company")
mycursor=_______________ #Statement 1
print("Employee with salary greater than 65000 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

300 | P a g e
3 What are the merits of using a csv file for storage? 5
3 Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an Library to a CSV file ‘books.csv’. Each record
consists of a list with field elements as bno, name,Author and type to store Book number
id, Book name, Author Name and Type of Book respectively.
OR
Give any one point of difference between a text file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
(i) update() – To accept and update data of a student to a CSV file ‘mark.csv’. Each
record consists of a list with field elements as sid, sname and sclass to store student id,
student name and student class respectively.
SECTION-E
3 Write SQL commands for the following queries based on the relation Teacher given
4 below:
4
Table: Teacher
N Ag Departme Date_of_jo Salar Se
o Name e nt in y x
1200
1 Jugal 34 Computer 10-01-1997 0 M
Sharmil 2000
2 a 31 History 24-03-1998 0 F
Sandee 3000
3 p 32 Maths 12-12-1996 0 M
Sangeet 4000
4 a 35 History 01-07-1999 0 F
2500
5 Rakesh 42 Maths 05-09-1997 0 M
3000
6 Shyam 50 History 27-06-1998 0 M
Shiv 2100
7 Om 44 Computer 25-02-1997 0 M
Shalak 2000
8 ha 33 Maths 31-07-1997 0 F
(i) To show all information about the teacher of Computer department.
(ii) To list the names of all teachers with their date of joining in descending order.
(iii) Write the statements to
a) Delete the record of teacher age greater than 45
b)Increase the salary of teachers by 15% whose department is history
OR

301 | P a g e
a) To count the number of teachers with age less than 35
b)Add column QUALIFICATION in the table with datatype as varchar with 50
characters.
3 Mr.Mathew is a Python programmer. who has recently joined the company and given a 4
5 task to write a python code to perform update operation in binary file(stud.dat)which
contain admno(Admission no) and fee(Fee paid by student).
He has succeeded in writing partial code and has missed out certain statement ,you as an
expect of python have to provide the missing statements.
import _______ #Statement 1
St={}
Flag=0
File=open("____________","rb+) #Statement 2
Search=int(input("Enter Admission number whose fee is to be updated :"))
Amt=int(input("How much to be incresed:"))
try:
while True:
Try:
Pos=file.tell()
St=pickle.load(file)
If st['admno']==search:
st['fee']+=amt
file._________(pos) #Statement 3

pickle.__________(st.file) #Statement 4

print("Record Updated")
flag=1
expect EOFError:
if flag=0:
print("Record not found")
file.close()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open binary file (Statement 2)
(iii) Which statement should be fill in Statement 3 to place the file pointer at specified position
and statement 4 used to store the data

302 | P a g e

You might also like