wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Revision Tour - I

Total questions: 15

Worksheet time: 5mins

Name
Class
Date
1.

Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[2:5])

a)

[6,82,5,7]

b)

[1,3,6,82,5]

c)

[6,82,5]

d)

None of these

2.

Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect?

a)

print(T[1])

b)

T[2] = -29

c)

print(max(T))

d)

print(len(T))

3.

A tuple is declared as

T = (2,5,6,9,8)

What will be the value of sum(T)?

a)

30

b)

0

c)

Error

d)

29

4.

If the following code is executed, what will be the output of the following code?

name="ComputerSciencewithPython"

print(name[3:10])

a)

puterSci

b)

puterSc

c)

mputerSc

d)

none

5.

The statement: bval=str1>str2 shall return __________________ as the output, if str1="Delhi" and str2="New Delhi".

a)

True

b)

Delhi

c)

New Delhi

d)

False

6.

Which of the following statements returns a list?

a)

tup(list)

b)

len(tup)

c)

list(string)

d)

dict(string)

7.

What is the output?

a=[5,10,15,20,25]

k=1

i=a[1]+1

j=a[2]+1

m=a[k+1]

print(i,j,m)

a)

11 15 16

b)

11 16 15

c)

11 15 15

d)

16 11 15

8.

Which of the function is used to iterate over a sequence of numbers by specifying a numeric end value within its parameters?

a)

range()

b)

len()

c)

substring()

d)

random()

9.

what is the output?

d={0:'a',1:'b',2:'c'}

for i in d:

print(i)

a)

0

1

2

b)

a

b

c

c)

0

a

1

b

2

c

d)

2

a

2

b

2

c

10.

what is the output?

x=123

for i in x:

print(i)

a)

1 2 3

b)

123

c)

error

d)

infinite loop

11.

suppose list1=[0.5* x for x in range(0,4)], list 1 is:

a)

[0,1,2,3]

b)

[0,1,2,3,4]

c)

[0.0,0.5, 1.0, 1.5]

d)

[0.0,0.5, 1.0, 1.5, 2.0]

12.

T=('A',('B','C',('d','E'),'F'),'G','H')

What is the length of the above tuple?

a)

8

b)

7

c)

6

d)

4

13.

T=('a','b','c')

Write the statement to unpack the values of the above Tuple with three different variables in a single statement.

a)

T=a,b,c

print(a,b,c)

b)

a b c =T

print(a,b,c)

c)

a,b,c=T

print(a,b,c)

d)

a=T

print(a)

14.

T=(2,5,6,9,8)

Which is the correct statement to print the tuple in ascending order using built in function?

a)

print(sort(T))

b)

print(sorted(T))

c)

print(sort(T) ascending)

d)

Not possible

15.

val=1,2,3,4,5

What will be the type of the variable 'val'?

a)

<Tuple>

b)

<List>

c)

<int>

d)

None of these