Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 8

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

What will be printed when the following executes?

str = "His shirt is red"

pos = str.find("is")

print(pos)

a)

1

b)

9

c)

2

d)

10

2.

What will be printed when the following executes?

str = "This is fun"

str = str[5]

print(str)

a)

i

b)

is fun

c)

is

d)

none of these

3.

What would the following code print?

flm= 5

print("Front" + " Line " + str(flm))

a)

Front Line flm

b)

Front Line 5

c)

5 Front Line

d)

None

4.

What is printed by the following statements?

s = "python rocks"

print(s[3])

a)

t

b)

h

c)

c

d)

Error

5.

s = "Front Line Media"

print(s[6] + s[-5])

a)

LM

b)

ML

c)

tL

d)

Lt

6.

s = "Front Line Media"

print(len(s))

a)

15

b)

13

c)

16

d)

None

7.

What is printed by the following statements:

s = "Rose"

s[1] = "i"

print(s)

a)

Rose

b)

Rise

c)

iose

d)

TypeError

8.

True or false: the string is immutable type in python

a)

True

b)

False

9.

Negative index -1 belongs to _____ of string

a)

first character

b)

last character

c)

second last character

d)

second character

10.

Which of the following functions will return the total number of characters in a string?

a)

count ()

b)

index ()

c)

len()

d)

all of these

11.

Which of the following functions will return the string in all caps ?

a)

upper ()

b)

toupper()

c)

isupper()

d)

to-upper()