Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python slicing

Total questions: 28

Worksheet time: 34mins

Name
Class
Date
1.

What is the output to the console for the featured program?

a)

Esteban

b)

Esteban Esteban

c)

teban

d)

steban

2.

What will be the output for the program above?

a)

<class 'tuple'>

b)

<class 'list'>

c)

<class 'set'>

d)

<class 'dict'>

3.

Which of the following prints the letter A?

a)
b)
c)
d)
4.

What is the output to the console for the featured program?

a)

Angel

b)

ngel

c)

gel

d)

el

5.

What is the output to the console for the featured program?

a)

Tiffany

b)

fany

c)

Tif

d)

Tiff

6.

What is the output to the console for the featured program?

a)

Samantha

b)

mant

c)

anth

d)

ant

7.

Which of the following prints the letter C?

a)
b)
c)
d)
8.

What is the output to the console for the featured program?

a)

8

b)

len(name)

c)

4

d)

Samantha

9.

What will be the output for the program above?

a)

<class 'tuple'>

b)

<class 'list'>

c)

<class 'set'>

d)

<class 'dict'>

10.

What is the output to the console for the featured program?

a)

8

b)

len(Edua)

c)

7

d)

4

11.

What is the output to the console for the featured program?

a)

False

b)

True

c)

cat

d)

concatenation

12.

What is the output to the console for the featured program?

a)

D

a

v

i

d

b)

David

c)

0

1

2

3

4

d)

5

13.

What is the output to the console for the featured program?

a)

D

a

v

i

d

b)

David

c)

0

1

2

3

4

d)

5

14.

Which of the following prints the letter D?

a)
b)
c)
d)

15.

What is the output to the console for the featured program?

a)

False

b)

True

c)

cat

d)

concatenation

16.

Which of the following prints CDE?

a)
b)
c)
d)
17.

What is the output to the console for the featured program?

a)

J

e

r

m

a

v

i

b)

Jermavi

c)

0

1

2

3

d)

m

a

v

i

18.

Which of these pieces of code would return the name "Alex" from the following list?

nameList = ["Andrea", "Alex", "Xavier", "Jose", "Quaylan"]

a)

nameList(1)

b)

nameList[1]

c)

nameList("Alex")

d)

nameList["1"]

19.

What is the output to the console for the featured program?

a)

G

a

b

r

i

e

l

b)

Gabriel

c)

0

1

2

3

4

5

6

d)

l

e

i

r

b

a

G

20.

Which of the following prints ABCDE?

a)
b)
c)
d)
21.

What is the correct way to concatenate the variable sign (sign = "Happy day!") to produce the following output?

expected output: “Happy Birthday!”

a)

print(sign[:5] + "Birth" + sign[6:])

b)

print(sign[:6] + "Birth" + sign[5:])

c)

print(sign[:6] + "Birth" + sign[:6])

d)

print(sign[:6] + "Birth" + sign[6:])

22.

What is the output to the console for the featured program?

a)

stress

b)

desserts

c)

dessert

d)

stressed

23.

What is the output to the console for the featured program?

a)

spam

b)

am

c)

sp

d)

maps

24.

What will be the output of the code above?

a)

['a', 'b', 'c', 'd', 'e']

b)

['e', 'd', 'c', 'b', 'a']

c)

['a', 'c', 'e']

d)

['e', 'c', 'a']

25.

What will be the output of the code above?

a)

ADGJMPSVY

b)

ABCDEFGHIJKLMNOPQRSTUVWXYZ

c)

ZYXWVUTSRQPONMLKJIHGFEDCB

d)

ZYXWV

26.

What will be the output of the code above?

a)

ADGJMPSVY

b)

ABCDEFGHIJKLMNOPQRSTUVWXYZ

c)

ACEGIKMOQSUWY

d)

AEIMQ

27.

What will be the output for the code above?

a)

0

2

4

b)

1

3

5

c)

Kristina

Carmen

Olga

Ke'Nyiah

Evelyn

Isabel

d)

Kristina

Olga

Evelyn

28.

What will be the output for the code above?

a)

0

2

4

b)

1

3

5

c)

Kristina

Carmen

Olga

Ke'Nyiah

Evelyn

Isabel

d)

Kristina

Olga

Evelyn