KV CRPF YELAHANKA, BENGALURU-64
SLIP TEST – 2 ( SQL, NETWORK )
Name : Date : 23/12/2022 Marks scored :
1 a) Give the output of the following:- b) Give the output of the following:- 2
Sum = 0 Sum = 0
for k in range(5): for k in range(10 , 1, -2):
Sum = Sum+k Sum = Sum+k
print(Sum) print(Sum)
2 a) Give the output of the following:- b) Give the output of the following:- 2
for k in range(4): L = [1,2,3,4,5,6,7,8,9]
for j in range(k): print(L[: -3])
print('*', end = '')
print()
3 a) Give the output of the following :- b) Give the output of the following :- 4
import random def fun():
a=random.randint(3,5) global a
b = random.randint(2,3) a=10
c=a+b print(a)
print(c) a=5
a) 4 b) 9 c) 7 d) all a,b,c fun()
print(a)
a) 10 b) 5 c) 10 d) 5
10 5 5 10
4 Write Python code to find whether the given item is present in the given list using loop. 2
5 Which of the following is a valid function name? 1
a) Start_game() b) start game() c) start-game() d) All of the above
6 What possible outputs are expected to be displayed on screen at the time of execution of 2
the program from the following code? Also specify the maximum value that can be assigned
to each of the variables L and U.
import random
Arr=[10,30,40,50,70,90,100]
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(Arr[i],"@",end="")
i) 40 @50 @ ii) 10 @50 @70 @90 @ iii) 40 @50 @70 @90 @ iv) 40 @100 @
7 Identify the module to which the following function load () belong to? 1
a) math b) random c) pickle d) sys
8 What possible output(s) are expected to be L=[10,7,21] 2
displayed on screen at the time of execution X=random.randint(1,2)
of the following code? Also specify the for i in range(X):
maximum and minimum value that can be Y=random.randint(1,X)
assigned to variable X. print(L[Y],"$",end=" ")
import random
(i)10 $ 7 $ (ii) 21 $ 7 $ (iii) 21 $ 10 $ (iv) 7 $
9 Write a function countVowels() in Python, which should read each character of a text file 3
“myfile.txt”, count the number of vowels and display the count.
Example: If the “myfile.txt” contents are as follows: This is my first class on Computer
Science.
The output of the function should be: Count of vowels in file: 10
10 Write read contents from story.txt and count no: of independent words “to” in the file. 2
11 Differentiate between XML and HTML 2
12 What is a protocol, give some examples? 2