Sample-Paper-Computer-Science-Paper
Sample-Paper-Computer-Science-Paper
PAPER
COMPUTER SCIENCE
Time 3 hrs Max. Marks : 70
General Instructions :
(i) This question paper contains five sections, Section A to E.
(iv) Section B have 7 Very Short Answer type questions carrying 2 marks each.
(v) Section C have 5 Short Answer type questions carrying 3 marks each.
®
(vi) Section D have 2 questions carrying 4 marks each.
(vii) Section E have 3 Long Answer type questions carrying 5 marks each. One internal choice is
given is Q.34 and 35, against Part (iii) only.
(viii) All programming questions are to be answered using Python Language only.
SECTION-A
1. State True or False:
A dictionary can be updated by the contents of other dictionary using the change () method. [1]
2. Jaya wants to display the records of her table in descending order of names of products. Which
SQL clause she has to use? [1]
(A) Group by (B) Order by (C) Between (D) Check
3. The expression: [1]
72//4 + 12 % 5 + 9**2 –1 evaluates to:
1
6. Bluetooth transmission can carry data within [1]
(A) A city (B) A country (C) A state (D) A room
7. What will be the output of this program? [1]
p = "12"
q = "5"
r = 10
s=8
print(p+q, r+s)
(A) 17 18 (B) 125 108 (C) 17 108 (D) 125 18
8. The score of a student in a test is stored as a Python tuple. The test has 3 questions, with some
questions having subparts whose scores are recorded separately. [1]
®
score = (6, (5, (2, 1), 8, (4, 3, (1, 3, 2))))
What will be the output of this program snippet?
(A) (1, 3, 2) (B) (2, 1) (C) 3 (D) 8
9. What will be the output of the program given below? [1]
string = "2021-08-09 10 : 22 : 03 :: 0443 :: 06384626 :: 00001024'"
parts = string.spilt("::", 2)
print(parts)
(A) ['2021-08-09 10:22:03', '0443::06384626: :00001024']
(B) ['2021-08-09 10', '22', '03::0443::06384626::00001024']
(C) ['2021-08-09 10:22:03', '0443','06384626::00001024']
(D) ['2021-08-09 10:22:03', '0443',06384626','00001024']
10. What possible output(s) are expected to be displayed on screen at the time of execution of the
program from the following code? [1]
import random
AR=[20,30,40,50,60,70]
From=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end='#')
(A) 10#40#70# (B) 30#40#50# (C) 50#60#70# (D) 40#50#70#
11. Fill in the blank: [1]
A cookie is a _________ .
(A) Temporary file (B) Protocol (C) Software (D) Hardware
2
12. Given the following code. What should be filled in the missing blank for proper execution of the
code, import random
def automatic() : #Function to return a random number between 0-1
s=random.______
return s
(A) randint(0,100) (B) random() (C) shuffle () (D) choice [1]
13. State True or False: [1]
The code written in the finally block executes every time, even if exception does not occur.
14. A table in a database can contain primary key(s). [1]
(A) Single (B) Multiple (C) 2 (D) 3
15. Fill in the blank; [1]
®
The function of a repeater is to take a weak and corrupted signal and _______ it.
16. Which of the following statement(s) are correct regarding the file access modes? [1]
(A) 'r+' opens a file for both reading and writing. File object points to its beginning.
(B) 'w+' opens a file for both writing and reading. Adds at the end of the existing file if it exists
and creates a new one if it does not exist.
(C) 'wb' opens a file for reading and writing in binary formal. Overwrites the file if it exists and
creates a new one if it does not exists.
(D) 'a' opens a file for appending. The file pointer is at the start of the file if the file exists.
3
SECTION-B
19. (a) Expand the following terms: [2]
POP3, URL
OR
20. The code given below accepts a number as an argument and returns the reverse number. Observe
the following code carefully and rewrite it after removing all syntax and logical errors. Underline
®
all the corrections made. [2]
define revNumber (num) :
rev = 0
rem = 0
While num > 0:
rem == num %10
rev = rev *10 + rem
num = num //10
return rev
print (revNumber (1234))
21. Write a function countNow (PLACES) in Python, that takes the dictionary, PLACES as an
argument and displays the names (in uppercase)of the places whose names are longer than
LONDON
NEW YORK
OR
Write a function, lenWords (STRING), that takes a string as an argument and returns a tuple
containing length of each word of a string. For example, if the string is "Come let us have some
4
22. Predict the output of the following code: [2]
S = "LOST"
L= [10 21 33 4]
D = { }
for I in range (len (s)) :
if 1% 2 ==0:
D[L. pop () ] = S[I]
else:
D[L. pop () ] = I + 3
for K, V in D. items ():
print (K, V, sep = "*")
®
23. Write the Python statement for each of the following tasks using BUILT- IN functions/methods
only: [2]
(a) To insert an element 2 0 0 at the third position, in the list LI.
(b) To check whether a string named, message ends with a full stop / period or not.
OR
A list named studentAge stores age of students of a class. Write the Python command to import
the required module and (using built-in function) to display the most common age value from the
given list.
24. Ms. Shalini has just created a table named "Employee" containing columns Ename,
Department and Salary. After creating the table, she realized that she has forgotten to add a
primary key column in the table. Help her in writing an SQL command to add a primary key
column Empld of integer type to the table Employee. Thereafter, write the command to insert
the following record in the table: [2]
Empld-999
Ename-Shweta
Department:Production
Salary:26900
OR
Zack is working in a database named SPORT, in which he has created a table named "Sports"
containing columns Sportld, SportName, no_of_players, and category.
After creating the table, he realized that the attribute, category has to be deleted from the table
and a new attribute TypeSport of data type string has to be added. This attribute TypeSport
cannot be left blank. Help Zack write the commands to complete both the tasks.
5
25. Predict the output of the following code: [2]
def Changer (P, Q = 10):
P = P/Q
Q = P%Q
return P
A = 200
B = 20
A = Changer (A, B)
print (A, B, sep = '$')
B = Changer (B)
Print (A, B, sep = '$', end = '###')
SECTION-C
®
26. Predict the output of the code given below : [3]
s="welcome2cs"
n - len(s)
m=""
for i in range(0,n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i],upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i–1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '&'
print(m)
27. Table:STUDENT [3]
RollNo Name Class DOB Gender City Marks
1 Nanda X 06-06-1995 M Agra 551
2 Saurabh XII 07-05-1993 M Mumbai 462
3 Sonal XI 06-05-1994 F Delhi 400
4 Trisla XII 08-08-1995 F Mumbai 450
5 Store XII 08-10-1995 M Delhi 369
6 Marisla XI 12-12-1994 F Dubai 250
7 Neha XI 08-12-1995 F Moscow 377
8 Nishant X 12-06-1995 M Moscow 489
(A) SELECT COUNT(*), city FROM STUDENT GROUP BY CITY HAVING COUNT (*)>i;
(B) SELECT MAX(DOB), MIN(DOB) FROM STUDENT;
(C) SELECT NAME,GENDER FROM STUDENT WHERE CITY="Delhi";
6
28. Write a method COUNTLINES() in Python to read lines from text file 'TESTFILE,TXT' and
display the lines which are not starting with any vowel.
Example :
If the file content is as follows:
An apple a day keeps the doctor away.
We allpray for everyone's safety.
A marked difference will come in our country.
The COUNTLINES () function should display the output as:
The number of lines not starting with any vowel-1 [3]
OR
®
Write a function, ETCount()in Python, which should read each character of a text file
"TESTFILE.TXT" and then count and display the count of occurrence of alphabets E and T
individually (including small cases e and t too). [3]
Example :
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
E or e:6
T or t:9
29. Consider the table Personal given below: [3]
Table: TRIP
NO NAME TDATE KM TCODE NOP
11 Tanish Khan 2015-12-13 200 101 32
13 Danish Sahai 2016-06-21 100 103 45
15 Ram Kumar 2016-02-23 350 102 42
12 Fen Shen 2016-01-13 90 102 40
17 Aan Kumar 2015-02-10 75 104 2
14 Veena 2016-06-28 80 105 4
16 Rajpal Kirti 2016-06-06 200 101 25
7
Note :
• NO is Driver Number
• KM is Kilometre travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Trip Date
Based on the table write SQL queries for the following :
(i) To display NO, NAME, TDATE from the table TRIP in descending order of NO.
(ii) To display the NAME of the drivers from the table TRIP, whoare travelling by transport
vehicle with code 101 or 103.
(iii) To display the NO and NAME of those drivers from the table TRIP, who travelled between
®
2015-02-10 and '2015-04-01' [3]
30. A list contains following record of a customer.
[Customer_name, Phone_number, City]
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 Phone number of customers who
live in Goa 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 :
["Gurdas", "99999999999", "Goa"]
["Julee", "8888888888", "Mumbai"]
["Murugan", "77777777777", "Cochin"]
["Ashmit", "1010101010", "Goa"]
The stack should contain
["Ashmit", "1010101010"]
["Gurdas", "9999999999"]
The output should be :
["Ashmit", "1010101010"]
["Gurdas", "9999999999"]
Stack Empty [3]
8
SECTION-D
31. Write SQL queries for (i) to (iv) based on the table School and Admin given below [4]
Table : School
CODE TEACHER SUBJECT DOJ PERIODS EXPERIENCE
1001 RAVI SHANKAR ENGLISH 12/3/2000 24 10
1009 PRIYA RAI PHYSICS 03/09/1998 26 12
1203 LIS ANAND ENGLISH 09/04/2000 27 5
1045 YASHRAJ MATHS 24/08/2000 24 15
1123 GANAN PHYSICS 16/07/1999 28 3
1167 HARISH B CHEMISTRY 19/10/1999 27 5
1215 UMESH PHYSICS 11/05/1998 22 16
®
TABLE : ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD
(i) To display each designation and count of each type for designations where count is <2.
(ii) To display the maximum experience.
(iii) To display names of teachers who have more than 12 years of experience in ascending
order of teacher name.
(iv) To display teacher names and corresponding designations from both the tables.
32. Rohini is a CS student and has been assigned by her teacher to write functions ADD() and
COUNTER() for working with records of employees.
(i) ADD () – To accept and add data of an employee to a CSV file 'record. csv'.Each
record consists of a list with field elements as empid, name and sal to store employee id,
employee name and employee salary respectively.
(ii) COUNTR () – To count the number of records present in the CSV file named 'record.
csv'. [4]
9
SECTION-E
33. ABC is professional consultancy company. The company is planning to set up their new offices
in India with its hub at Bengaluru. As a network adviser, you have to understand their
requirements and suggest them the best available solutions. Their queries are mentioned as (i) to
(v) below: Physical Location of the blocks of ABC.
Human Resource Conference Finance
Block to Block Distances (int Mtr)
Block (From) Block (To) Distance
Human Resource Conference 110
Human Resource Finance 40
Conference Finance 80
Expected number of computers to be installed in each block:
®
Block Computer
Human Resource 25
Finance 120
Conference 90
(i) What will be the most appropriate block, where ABC should plan to install their server?
(ii) Which type of topology is best suited for above network?
(iii) What will be the best possible connectivity you will suggest to connect the new setup of
offices in Chennai with its London based office.
(iv) Which device will be suggested by you to connect each computer in each of the buildings?
(v) The company wants internet accessibility in all the blocks. What would the suitable and
cost-effective technology for that? [5]
34. (i) What happens when we use file open () function in Python ?
(ii) Create file phonebook.txt that stores the details in following format:
Name Phone
Jivin 86666000
Kriti 1010101
Obtain the details from the user. [5]
OR
(i) What is closed attribute of a file object?
(ii) A file phonebook.txt stores the details in the following format:
Name Phone
Jivin 86666000
Kriti 101001
Write a program to edit the phone numbers of "Arvind" in file. If there is no record for
"Arvind" report error.
10
35. (i) Define the term Join with respect to RDBMS.
(ii) Consider the tables Product and Client with structures as follows:
Product Client
P_ID C_ID
ProductName CName
Manufacturer CCity
Price CProd
Write Python codes to display the details of products whose price is in range of 50 to 100
Both values included. Use the following information for connection.
Host: localhost
Database: cosmetics
®
Userid : Admin
Password : Admin@123
Table name : Product [5]
OR
(i) MySQL supports different character sets, which command is used to display all character
sets?
(ii) Consider the tables Product and Client with structures as follows:
Product Client
P_ID C_ID
ProductName CName
Manufacturer CCity
Price CProd
Write Python code to display the Client Name, City from table Client
11