Computer Science Sample Paper
Computer Science Sample Paper
Maximum Marks: 70
General Instructions:
Section A
1. State true or false:
l1.append([5,6,[7,8,[9,10])
>>> str[:2]
a) he
b) llo
c) ello
d) hel
11. Which of the following is not an inherent application of stack?
a) Implementation of recursion
b) Evaluation of postfix expression
c) Job scheduling
d) Reversing a string
12. It is a way to convey a Python object into a character stream:
a) Unpickling
b) Pickling
c) dump() method
d) load() method
13. What is the full form of CSMA/CA?
a) Collision Sense Multiple Access/Collision Act
b) Carrier Sense Multiple Access/Collision Avoidance
c) Carrier Sense Multiple Access/Collision Act
d) Collision Sense Multiple Access/Collision Avoidance
14. A copy of the dictionary where only the copy of the keys is created for the new dictionary, is called ________ copy.
Reason (R): By using "w" access mode, It overwrites the existing file.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
Section B
19. What is collision in a network? How does it impact the performance of a network?
20. What will be the output?
dic = {'One':1,'Two':2,'Three':3}
print(list(dic.values()))
OR
Write a Python program to remove the characters of odd index values in a string.
21. Consider the following table order-details of database sales
ORDNUMB PARTNUMB NUMBORD QUOTPRIC
import random
PICKER = random.randint(0, 3)
for I in COLOR :
print()
(i) (ii) (iii) (iv)
BLUE BLUE PINK BLUEBLUE
OR
i. str [3 : 5]
ii. str [- 10]
iii. str [5 : ]
iv. str [- 28]
25. Given a text file car.txt following information of cars carNo, carname, containing mileage. Write a Python function to
display details of all those cars whose mileage is from 100 to 150.
OR
Write code to print just the last line of a text file "data.txt".
Section C
26. Answer:
i. What is the length of the tuple shown below?
t[0] = 6
ii. t = [1, "a", 9.2]
t[0] = 6
iii. t = [1, "a", 9.2]
t[4] = 6
t[0] = "H"
27. Give the output of the following SQL statements, which are based on the table APPLICANTS.
TABLE: APPLICANTS
OR
i. A table, ITEM has been created in a database with the following fields
Give the SQL command to add a new field, DISCOUNT (of type Integer) to the ITEM table.
ii. Categorize following commands into DDL and DML commands?
INDIA.TXT
"India is the fastest-growing economy. India is looking for more investments around the globe. The whole world is
looking at India as a great market. Most of the Indians can foresee the heights that India is capable of reaching."
30. What is the difference between a local variable and a global variable? Also, give a suitable Python code to illustrate both.
OR
s1 = obj1.readline()
s2.readline(10)
s3 = obj1.read(15)
print(s3)
print(obj1.readline())
obj1.close()
iii. Your recipe uses some ingredients. Write a program to store the list of ingredients in a binary file.
iv. Write code to open file contacts.txt with shown information and print it in the following form:
Name : <name>
Table: GARMENT
OR
Write SQL commands for the queries (i) to (iv) and output for (v) to (viii) based on the tables 'Watches' and Sale given
below.
Watches
Sale
W003 5 1
W002 20 2
W003 10 2
W001 15 3
W002 20 3
W005 10 3
W003 15 4
i. TO DISPLAY ALL THE DETAILS OF THOSE WATCHES WHOSE NAME ENDS WITH TIME.
ii. TO DISPLAY WATCH'S NAME AND PRICE OF THOSE WATCHES WHICH HAVE PRICE RANGE IN
BETWEEN 5000-15000.
iii. TO DISPLAY TOTAL QUANTITY IN-STORE OF UNISEX TYPE WATCHES.
iv. TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN the FIRST QUARTER.
v. SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
vi. SELECT QUARTER, SUM(QTY_SOLD) FROM SALE GROUP BY QUARTER;
vii. SELECT WATCHNAME, PRICE, TYPE FROM WATCHES W, SALE S WHERE W. WATCHID!= S.WATCHID;
viii. SELECT WATCHNAME, QTYSTORE, SUM (QTYSOLD), QTY_STORE - SUM (QTY_SOLD) "STOCK" FROM
WATCHES W, SALE S WHERE W. WATCHID = S.WATCHID GROUP BY S.WATCHID;
Section E
34. Read the text carefully and answer the questions:
Granuda Consultants are setting up a secured network for their office campus at Faridabad for their day to day office and
web-based activities. They are planning to have connectivity between 3 buildings and the head office situated in
Head Office 10
i. Suggest the most suitable place (i.e.r block) to house the server of this organization. Also, give a reason to
justify your suggested location.
ii. What type of network will be formed if all buildings are connected?
iii. Suggest the placement of the following devices with justification:
i. Switch
ii. Repeater
OR
The organization is planning to provide a high-speed link with its head office situated in the KOLKATA using a
wired connection. Name the cabels will be most suitable for this job?
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create similar
papers with their own name and logo.
35. Read the text carefully and answer the questions:
Table: ACTIVITY
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003
i. Write SQL commands for the following statements:
i. To display the names of all activities with their Acodes in descending order.
ii. To display sum of PrizeMoney for the Activities played in each of the Stadium separately.
ii. Write SQL commands for the following statements:
i. To display the coach's name and Acodes in ascending order of Acode from the table Coach.
ii. To display the content of the Activity table whose schedule date earlier than 01-01-2004 in ascending order
of Participants Num.
iii. Give the output of the following SQL queries:
i. SELECT COUNT (DISTINCT Participants Num) FROM ACTIVITY;
ii. SELECT MAX (Schedule Date), Min (Schedule Date) FROM ACTIVITY;
Solution
Section A
1. (b) False
Explanation: False
2. (c) SELECT city, temperature FROM weather ORDER BY temperature;
Explanation: The ORDER BY keyword sorts the records in ascending order by default.
3. (a) fetchtwo( )
Explanation: The built-in functions min(), max (), divmod(), ord(), any(), all() etc. throw an error when no arguments
are passed to them. However there are some built-in functions like float(), complex() etc. which do not throw an error.
5. (a) 0000
Explanation: A list is getting added in list l1 which will be counted as one item for the list.
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create similar
papers with their own name and logo.
8. (b) Fixed, variable
Explanation: Char has a specific length which has to be filled by either letters or spaces whereas Varchar changes its
length accordingly .
9. (b) file
Explanation: File is a named entity stored in storage drive that contains stream of data.
10. (a) he
Explanation: str[:2] prints only the values at index 0 and 1 (as 2 is exclusive) of string and hence the answer is “he”.
11. (c) Job scheduling
Explanation: Pickling
13. (b) Carrier Sense Multiple Access/Collision Avoidance
Explanation: Carrier-sense multiple access with collision avoidance (CSMA/CA) in computer networking, is a network
multiple access method in which carrier sensing is used.
14. (a) shallow copy
Explanation: VB Script and Java Script are examples of client-side scripting languages. Rest all are server-side scripting
languages.
16. (d) Bus
Explanation: Bus
Explanation: Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating-point
numbers, Python objects, etc.). The axis labels are collectively referred to as the index. if data is an array, an index must
be the same length as the data.
18. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: In append mode, python creates a new file with the specified name if no such file exists. It appends the
content to the file if the file already exists with the specified name. In write mode, python creates a new file with the
specified name if no such file exists. It overwrites the existing file.
Section B
19. In a computer network, collision is a specific condition that occurs when two or more nodes on a network transmit data
at the same time. For example, if two computers on an Ethernet network send data at the same moment, the data will
"collide" and not finish transmitting. In case of a collision, the data gets garbled and cannot be read. Also, it may hamper
the overall performance of the network as collisions often lead to more retransmissions which clog the network and
deteriorate the overall performance of the network.
20. [1, 2, 3]
OR
final = ""
for i in range (len (str1)):
if (i% 2==0):
cursor = db.cursor()
check_value = (100, 3)
try:
db.commit ()
except:
db.rollback()
db.close()
22. Answer:
i. The connect( ) function can be used to connect with a database from within Python.
ii. No, You need to download separate DB-API for each database you need to access. It defines a standard interface for
Python database access modules.
23. Option (i) and (iv) are possible.
(i) If Value of PICKER is 2 (iv) If Value of PICKER is 3
BLUE BLUEBLUE
PINK PINKPINK
RED REDRED
PICKER can have a maximum value of 3 and a minimum value of 0.
d4 = {}
d4.update(i)
print(d4)
OR
i. ho
ii. ‘o’
iii. n Program
iv. IndexError
25. def display_car():
car_file = open('car.txt','r')
cars = file.readlines()
car_file.close()
mileage = (int)(temp[2])
print(car)
display_car()
OR
lines = file_obj.readlines()
lastline = len(lines) - 1
t1 = "a", 1
t3 = t2, "d", 2
t = (t3, "e", 3)
ii. i. Item assignment not possible for tuples as tuples are immutable types.
ii. No error.
iii. Error, Item being assigned to an invalid index (index out of range).
iv. Item assignment not possible for strings as strings are immutable types.
Avisha 2009
ii. MIN(JOINYEAR)
2009
iii. AVG(FEE)
31666.666
OR
return False
else:
if str1[i] != str2[i]:
return False
else:
return True
if stringCompare(first_string, second_string):
else:
count = 0
Words = LINE.split()
for W in Words:
if W == " India":
count = count+1
print(count)
file.close()
30. The differences between a local variable and a global variable are as given below :
Local Variable Global Variable
1. It is a variable which is declared within a function or within a 1. It is a variable which is declared outside all the
block functions
2. It is accessible only within a function/block in which it is 2. It is accessible throughout the program
3. Local variables are created when the function has started 3. Global variable is created as execution starts
execution and are lost when the function terminates. and is lost when the program ends.
For example, in the following code, x, xCubed are global variables and n and cn are local variables.
def cube(n):
cn = n * n * n
return cn
x = 10
xCubed = cube(x)
OR
top = 0
def isEmpty ( ):
global top
return top == 0
def push(x):
global stack,top
return
stack[top]= x
top += 1
def pop( ):
global stack,top
if isEmpty( ):
return
else:
top -= 1
return stack[top]
for i in string:
x = pop( )
32. Answer (i) & (ii) OR (iii) & (iv)
i. def Readfile():
i=open("Employee.dat", "rb+")
x=i.readline()
while(x):
l=x.split(':')
if (20000>=float(1[2])<=40000):
print(x)
x=i.readline()
ii. The above code raises an error as there has been no file object defined/created by the name s2, which is directly used
in line 3. Therefore, the code will not give any output.
iii. import pickle
pickle.dump(ingredients, fout)
iv. file_obj = open("contacts.txt", "r")
line = file.read( )
info = line.split(',')
file_obj.close( )
33. i. SELECT GCODE, Description FROM GARMENT ORDER BY GCODE DESC ;
ii. SELECT * FROM GARMENT WHERE READY DATE BETWEEN '08-DEC-07' AND '16-JUN-08' ;
iii. SELECT AVG(Price) FROM GARMENT WHERE FCODE = 'F03' ;
iv. SELECT FCODE, MAX(Price), MIN(Price) FROM GARMENT GROUP BY FCODE ;
OR
25000 100
2 30
3 45
OR
Optical Fibre
35. i. i. SELECT Acodes, ActivityName FROM ACTIVITY ORDER BY ACode DESC;
ii. SELECT SUM(PrizeMoney) FROM ACTIVITY GROUP BY Stadium;
ii. i. SELECT Name, Acode FROM COACH ORDER BY Acode;
ii. SELECT * FROM ACTIVITY WHERE SchduleDate < '01-Jan-2004' ORDER BY ParticipantsNum;
iii. i. 3
ii. 12-Dec-2003 19-Mar-2004