wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Unit 6 Sequences Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

2.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

3.

Which of code is correct for creating a list of numbers?

a)

num = (10,29,37,109)

b)

num = [10,29,37,109]

c)

num == (10,29,37,109)

d)

num = ['10 29 37 109']

4.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

5.

The correct syntax of the len function for string x:

a)

x.len()

b)

len[x]

c)

LEN[]

d)

len(x)

6.

The correct syntax for converting the string x to uppercase is :

a)

upper.x()

b)

upper(x)

c)

x.UPPER[ ]

d)

x.upper()

7.

x= "JavaLava", the output of print( x[len(x): ] ) is

a)

a

b)

Error. Index out of range

c)

JavaLava

d)

J

8.

Let x= "python is a high level language", the output of print(x[5].replace("n","*")) is

a)

pytho* is a high level language

b)

python is a high level language

c)

*

d)

Error

9.

Let x= "python is a high level language", the output of print(len(x[-1])) is

a)

1

b)

31

c)

Error

d)

25

10.

Let x= "Python is a high level language", the output of print(x[2].upper()+x[3].lower()+x[-1]) is

a)

THE

b)

The

c)

ThE

d)

the

11.

Given s = "Python", choose the Python code that DOES NOT give the output 6

a)

print(len(s))

b)

print(s.len())

c)

print(s.replace("Python","6"))

d)

print(len(s[ : len(s)] ))

12.

Let x= "Python", the output of

print(x[0])

print(x[-1])

print(x[-2])

a)

P

N

O

b)

p

O

n

c)

t

h

y

d)

P

n

o

13.

Which of the following functions is used to count the number of elements in a list ?

a)

count( )

b)

find( )

c)

len( )

d)

index( )

14.

Let list1=[2,4,6,8,10] then print(list1[-2]) will result in

a)

10

b)

8

c)

4

d)

6

15.

If list=[10,20,30,40,50] then list[2]=35 will result

a)

[35,10,20,30,40,50]

b)

[10,20,30,40,50,35]

c)

[10,20,35,40,50]

d)

[10,35,30,40,50]

16.

If list=[17,23,41,10] then list.append(32) will result

a)

[32,17,23,41,10]

b)

[17,23,41,10,32]

c)

[10,17,23,32,41]

d)

[41,32,23,17,10]

17.

What type of data is: a=[(1,1),(2,4),(3,9)]?

a)

Array of tuples

b)

List of tuples

c)

Tuples of lists

d)

Invalid type

18.

If L1=[2, 4, 8, 16] and L2=[32, 64]

what will result from L1+L2?

a)

[2,4,8,16,32,64]

b)

[2,4,8,16][32,64]

c)

[2,4,8,16],[32,64]

d)

2468163264

19.

What is the index number for 'Spain'?

['England','Brazil','Spain','France']

a)

0

b)

1

c)

2

d)

3

20.

Let x= "JavaLava", the output of print(x.rfind("v") ) is

a)

3

b)

6

c)

2

d)

7