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

KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION

SAMPLE PAPER SET – 8


CLASS – XII Subject: COMPUTER SCIENCE
Maximum Marks: 70 Time Allotted: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 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. Which of the following is an invalid identifier? 1


(a) true
(b) print
(c) 4ever
(d) While
2. Consider the following expression 1
5+2**6<9+2-16//8
Which of the following will be correct output if the given expression is evaluated?
(a) 127
(b) False
(c) True
(d) Invalid expression
3. State True or False 1
“ There is no conceptual limit to the size of a list.”
4. Which of the following options will not result in an error when performed on types in 1
python where tp = (5,2,7,0,3) ?
(a) tp[1] = 22
(b) tp.append(23)
(c) tp1 = tp+tp*2
(d) tp.sum()
5. Select the correct output of the code: 1
mystr = ‘Python programming is fun!’
mystr = mystr.partition(‘pro’)
mystr=’$’.join(mystr)
(a) Python $programming is fun!
(b) Python $pro$gramming is fun!
(c) Python$ pro$ gramming is fun!$
(d) P$ython $p$ro$gramming is $fun!
6. Which of the following commands is used to open a file “c:\test.txt” for reading and 1
writing data in binary format only.
(a) myfile = open(‘c:\\test.txt’,’rb+’)
(b) myfile = open(‘c:\test.txt\’,’wb’)

1
(c) myfile = open(‘c:\test.txt’,’w+’)
(d) myfile = open(‘c:\\test.txt’,’rb’)
7. Which of the following operators can take wild card characters for query condition? 1
(a) BETWEEN
(b) LIKE
(c) IN
(d) NOT
8. In SQL, which of the following will select only one copy of each set of duplicable rows 1
from a table?
(a) SELECT UNIQUE
(b) SELECT DISTINCT
(c) SELECT DIFFERENT
(d) All of these
9. Given tp = (1,2,3,4,5,6). Which of the following two statements will give the same 1
output?
1. print(tp[:-1])
2. print(tp[0:5])
3. print(tp[0:4])
4. print(tp[-4:])

(a) Statement 1 and 2


(b) Statement 2 and 4
(c) Statement 1 and 4
(d) Statement 1 and 3
10. The primary key is selected from the set of ____________ 1
(a) Composite keys
(b) Determinants
(c) Candidate keys
(d) Foreign keys
11. Which of the following functions do you use to write data in the binary format? 1
(a) write()
(b) output()
(c) dump()
(d) send()
12 In SQL, which command is used to change a table’s structure/characteristics? 1
(a) ALTER TABLE
(b) MODIFY TABLE
(c) CHANGE TABLE
(d) DESCRIBE TABLE
13. Your school has four branches spread across the city. A computer network created by 1
connecting the computers of computer labs of all the school branches, is an example
of _________.
(a) LAN
(b) MAN
(c) WAN
(d) PAN
14. What will be the following expression be evaluated to in Python? 1
print(5*2-5//9+2.0+bool(100))
(a) 11.0
(b) 13.0
(c) 112.0

2
(d) 100
15. Which clause is used with “aggregate functions” ? 1
(a) GROUP BY
(b) SELECT
(c) WHERE
(d) Both (a) and (c)
16. To fetch one record from the result set, you may use <cursor>.______ method: 1
(a) fetch()
(b) fetchone()
(c) fetchsingle()
(d) fetchtuple()
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); Binary file is faster than text file, so it is mostly used for storing data. 1

Reasoning (R): Text file stores less characters as compared to the binary file.
18. Assertion (A); A variable is still valid if it is not defined inside the function. The values 1
defined in global scope can be used.

Reasoning (R): Python used LEGB rule to resolve the scope of a variable.

SECTION B

19. Sumit is trying to write a program to find the factorial of a number passed to the 2
function and he has written the following code but it’s not working and producing
errors. Help Sumit to correct this and rewrite the corrected code. Also underline the
corrections made.

Def prime (num):


factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
else num == 0
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
20. What is the difference between a hub and a switch? 2
OR
Differentiate between Bus Topology and Star Topology of Networks. What are the
advantages and disadvantages of Star Topology over Bus Topology ?
21. (a) Convert the following for loop into while loop: 2

name = ‘ Karim Benzema’


for index in range(len(name)):
print(name[index].upper(),end=’’)

3
(b) Write the output of the following code given below:

Marks = {‘Sidhi’:65,’Prakul’:62,’Suchitra’:64,’Prashant’:50}
newMarks = {‘Suchitra’:66,’Arun’:55,’Prashant’:49}
Marks.update(newMarks)
for key,value in Marks.items():
print(key,’scored’,value,’marks in Pre Board’,end= ‘ ‘)
if(value<55):
print(‘and needs imporovement’end=’.’)

print()
22. Explain Referential Integrity in a Relational Database Management System. Why DBMS 2
is better than File System.
23. (a) Write full forms of the following: 2
(i) SMTP
(ii) IMAP
(b) What is MAC address?
24. Predict the output of the Python code given below: 2

def change(A):
S=0
for i in range(len(A)//2):
S+=(A[i]*2)
return S
B = [10,11,12,30,32,34,35,38,40,2]
C = change(B)
print('Output is',C)

OR

Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times = Times + C
Alpha = Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
25. What is the difference between CHAR and VARCHAR ? Write 2-3 differences. 2
OR
Differentiate between a Candidate Key and Alternate Key.

SECTION C

26. (a) Consider the following tables CUSTOMER and TRANSACTION: 1+2
Table: CUSTOMER
ACNO NAME GENDER BALANCE
C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750

4
Table: TRANSACTIONS
ACNO TDATE AMOUNT TYPE
C1 2022-07-21 1000 DEBIT
C2 2022-08-31 1500 CREDIT
C3 2022-09-15 2000 CREDIT

What will be the output of the following statement?

SELECT NAME, TDATE, AMOUNT FROM CUSTOMER C, TRANSACTION T WHERE C.ACNO


= T.ACNO AND TYPE = 'CREDIT';

(b) Write the output of the queries (i) to (iv) based on the tables, ACCOUNT and
TRANSACT given below:

Table: ACCOUNT
ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh

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) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN


('CHENNAI', 'BANGALORE');
(ii) SELECT DISTINCT ANO FROM TRANSACT;
(iii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT GROUP BY
ANO HAVING COUNT(*)> 1;
(iv) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT WHERE DOT <=
'2017-06-01';
27. Write the definition of a function ChangeGender() in Python, which reads the contents 3
of a text file "BIOPIC.TXT" and displays the content of the file with every occurrence of
the word 'he' replaced by 'she'. For example,

if the content of the file "BIOPIC.TXT" is as follows :

5
Last time he went to Agra,
there was too much crowd, which he did not like.
So this time he decided to visit some hill station.

The function should read the file content and display the output as follows:

Last time she went to Agra,


there was too much crowd, which she did not like.
So this time she decided to visit some hill station.

OR

Write a method/function BIGWORDS() in Python to read contents from a text file


CODE.TXT, to count and display the occurrence of those words, which are having 5 or
more alphabets.

For example :
If the content of the file is
ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE

The method/function should display


Count of big words is 5
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations TRAINS and 3
PASSANGERS given below:

Table: TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi

Table: PASSANGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12

(i) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;


(ii) SELECT MIN (TRAVELDATE), MAX (TRAVELDATE) FROM PASSENGERS
WHERE GENDER = 'MALE';
(iii) SELECT START, COUNT(*) FROM TRAINS GROUP BY START HAVING COUNT
(*)>1;
(iv) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T.TNO =
6
P.TNO AND AGE BETWEEN 40 AND 50;

(b) Write a query/command to display the structure of a table.


29. Define a function ZeroEnding(SCORES) to add all those values in the list of SCORES, 3
which are ending with zero (0) and display the sum.
For example :
If the SCORES contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600
30. A list contains following record of a student: 3
[student_name, marks, subject]
Write the following user defined functions to perform given operations on the stack
named ‘status’:
(i) Push_element() - To Push an object containing name and marks of a student who
scored more than 75 marks in ‘CS’ to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display
“Stack Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:

[“Danish”,80,”Maths”]
[“Hazik”,79,”CS”]
[“Parnik”,95,”Bio”]
[“Danish”,70,”CS”]
[“Sidhi”,99,”CS”]

The stack should contain


[“Hazik”,”79”]
[“Sidhi”,”99”]

The output should be:

[“Hazik”,”79”]
[“Sidhi”,”99”]
Stack Empty
OR

Write a function in Python, Push(emp) where , emp is a dictionary containing the


details of employees – {empname:salary}.
The function should push the names of those employees in the stack who have salary
less than 15000. Also display the count of elements pushed into the stack.
For example:

If the dictionary contains the following data:

Employee ={"Sohan”:20000,”Mohan”:9000,”Rohan”:25000,”Aman”:5000}
The stack should contain
Mohan
Aman

The output should be:


The count of elements in the stack is 2
SECTION D
7
31. Ayurveda Training Educational Institute is setting up its centre in Hyderabad with four 5
specialised departments for Orthopedics, Neurology and Pediatrics along with an
administrative office in separate buildings. The physical distances between these
department buildings and the number of computers to be installed in these
departments and administrative office are given as follows.
You, as a network expert, have to answer the queries as raised by them in (i) to (iv).

Shortest distances between various locations in metres :

Administrative Office to Orthopedics Unit 55


Neurology Unit to Administrative Office 30
Orthopedics Unit to Neurology Unit 70
Pediatrics Unit to Neurology Unit 50
Pediatrics Unit to Administrative Office 40
Pediatrics Unit to Orthopedics Unit 110

Number of Computers installed at various locations are as follows

Pediatrics Unit 40
Administrative Office 140
Neurology 50
Orthopedics Unit 80

ADMINSISTRATIVE OFFICE

ORTHOPEDICS OFFICE PEDIATRICS UNIT

NEUROLOGY UNIT

(i) Suggest the most suitable location to install the main server of this
institution to get efficient connectivity.
(ii) Suggest the best cable layout for effective network connectivity of the
building having server with all the other buildings.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
• Switch
• Gateway

(iv) Suggest a device/software to be installed in the given network to take care of


data security.
(v) Suggest an efficient as well as economic wired medium to be used within each
unit for connecting computer systems out of the following network cable :
8
Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
32. (a) Write the output of the code given below: 2+3

def myfunction(str1):
rstr1 = ‘’
index = len(str1)
while index>0:
if str1[index-1].isalpha():
rstr1+=str1[index-1]
index = index-1
return rstr1
print(myfunction(‘1234abcd’))

(b)
The code given below updates the record of table EMP by increasing salary by
1000Rs. of all those employees who are getting less than 80000Rs.

empno – integer
empname – string
salary – float

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is admin
The table exists in a MYSQL database named abcinfo.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to update the records as mentioned in the question
Statement 3- to add the record permanently in the database

import mysql.connector as ms
db1 = ms.connect(host=’localhost’,user=’root’,passwd=’admin’,database=’abcinfo’)
cur = __________ #Statement 1
sql = ‘UPDATE ____ ________________’ #Statement 2
______ _______ #Statement 3
print(‘Data Updated successfully’)
OR
(a) What possible output(s) is/are expected to be displayed on the screen at the
time of execution of the program from the following code ? Also specify the
maximum and minimum value that can be assigned to the variable R when K
is assigned value as 2.
import random
Signal = [ 'Stop', 'Wait', 'Go' ]
for K in range(2, 0, -1):
R = random.randrange(K)
print (Signal[R], end = ' # ')

(a) Stop # Wait # Go #


(b) Wait # Stop #
(c) Go # Wait #
(d) Go # Stop #

9
(b) The code given below inserts the following record in the table employee:
empID – integer
empName – string
salary – float
dept – sting
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is admin
 The table exists in a MYSQL database named empdata.
 The details (empID, empName, salary and dept) 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
Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",password="admin",
database="empdata")
mycursor=_________________ #Statement 1
empID =int(input("Enter employee ID :: "))
empName=input("Enter employee name :: ")
salary =float(input("Enter salary :: "))
dept= input("Enter department :: ")
querry="insert into employee
values({},'{}',{},{})".format(empID,empName,salary,dept)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
33. What is the full form of CSV? 5
Write a Program in Python that defines and calls the following user defined functions:
A csv file "PLANTS.csv" has structure [ID, NAME, PRICE].
 WRITEREC() - to input data for records from the user and write them to the file
PLANTS.csv. Each record consists of a list with field elements as ID, NAME and
PRICE to store plant id, plant name and price respectively
 SHOWHIGH() - To read the records of PLANTS.csv and displays those records
for which the PRICE is more than 500.

OR

What is the difference between a text file and a binary file?


Write a Program in Python that defines and calls the following user defined functions:

A csv file "PATIENTS.csv" has structure [PID, NAME, DISEASE].


Write the definition of a function countrec()in Python that would read contents
of the file "PATIENTS.csv" and display the details of those patients who have
the DISEASE as 'COVID-19'. The function should also display the total number
of such patients whose DISEASE is 'COVID-19'.
SECTION E
34. Pravesh is a database administrator for a company and has created the following 1+1+2
table:
10
Table: MOVIEDETAILS
MOVIEID TITLE LANGUAGE RATING PLATFORM
M001 Minari Korean 5 Netflix
M004 MGR Magar Tamil 4 Hotstar
M010 Kaagaz Hindi 3 Zee 5
M011 Harry Potter English 4 Prime Video
M015 Uri Hindi 5 Zee5
M020 Avengers: English 4 Hotstar
Endgame

(a) Identify the degree and cardinality of the table.


(b) Which field should be made the primary key? Justify your answer.
(c) Write the statements to:
(i) Delete the Records where the rating is less than 4
(ii) Update the rating of Movie having ID as M020 to 5.
OR
(c) Write the statements to
(i) Add another column called Recommended having default value of
‘Recommended’.
(ii) Increase the ratings of all Hindi movies by 1.
35. Aaruni Shah is learning to work with Binary files in python using a process knows as 4
pickling/de-pickling. Her teacher has given her the following incomplete code, which is
creating a binary file namely Mydata.dat and then opens , reads and displays the
content of the created files.
________________ #Fill_Line 1
sqlist = list()
for k in range(10):
sqlist.append(k*k)
fout = ______________‘ #Fill_Line2A
____________________ #Fill_Line3
fout.close()
fin = __________________ #Fill_Line2B
______________________ #Fill_Line4
fin.close()
print(“Data from file:”,mylist)

Help her complete the above code as per the instructions given below:

(a) Complete Fill_Line1 so that the required Python library becomes available to
the program.
(b) Complete Fill_Line2A so that the above mentioned binary file is opened for
writing in the file object fout.
Similarly, complete Fill_Line2B, which will open the same binary file for reading
in the file object fin.
(c) Complete Fill_Line3 so that the list created in the code, namely Sqlist is written
in the open file.
(d) Complete Fill_Line4 so that the contents of the open file in the file handle fin
are read in a list namely mylist.

11

You might also like