Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

RETEST

COMPPUTER SCIENCE

Full Marks :10 Time:15 minutes

1. What is the value of L at the end of execution of the following program?

L = [2e-04, 'a', False, 87]

T = (6.22, 'boy', True, 554)

for i in range(len(L)):

if L[i]:

L[i] = L[i] + T[i]

else:

T[i] = L[i] + T[i]

break

a) [6.222e-04, ‘aboy’, True, 641]

b) [6.2202, ‘aboy’, 1, 641]

c) TypeError

d) [6.2202, ‘aboy’, False, 87]

2. What is the output of the following program?

line = "I'll come by then."

eline = ""

for i in line:

eline += chr(ord(i)+3)
print(eline)

a) L*oo frph e| wkhq1

b) L*oo#frph#e|#wkhq1

c) l*oo@frph@e|$wkhq1

d) O*oo#Frph#E|#wKhq1

3. What is the output of the following program?

data = [x for x in range(5)]

temp = [x for x in range(7)

if x in data and x%2==0]

print(temp)

a) [0, 2, 4, 6]

b) [0, 2, 4]

c) [0, 1, 2, 3, 4, 5]

d) Runtime error

4. Whats is the output of the following program?

temp = 'Goodss 22536 for 445 Goods'

data = [x for x in (int(x) for x in temp if x.isdigit()) if x%2 == 0]

print(data)

a) [2, 2, 6, 4, 4]

b) Compilation error

c) Runtime error

d) [‘2’, ‘2’, ‘5’, ‘3’, ‘6’, ‘4’, ‘4’, ‘5’]

5. What will be the output of the following Python code?


i=0

while i < 5:

print(i)

i += 1

if i == 3:

break

else:

print(0)

a) 0 1 2 0

b) 0 1 2

c) error

d) none of the mentioned

6. What will be the output of given Python code?

str1="hello"

c=0

for x in str1:

if(x!="l"):

c=c+1

else:

pass

print(c)

7. What will be the output of the following code?


x = "abcdef"
i = "i"

while i in x:

print(i, end=" ")


A. a b c d e f
B. abcdef
C. i i i i i.....
D. No Output
8. What will be the output of the following Python code?
for i in range(0,2,-1):

print("Hello")

A. Hello
B. Hello Hello
C. No Output
D. Error

9. What will be the output of given Python code?


n=7

c=0

while(n):

if(n>5):

c=c+n-1

n=n-1

else:

break

print(n)

print(c)
10. Which of the following sequences would be generated bt the given
line of code?

range (5, 0, -2)

A. 5 4 3 2 1 0 -1
B. 5 4 3 2 1 0
C. 5 3 1
D. None of the above

You might also like