wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

python(strings)

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

example = "helle"

print(example.rfind("e") )

a)

-4

b)

4

c)

3

d)

1

2.

example="helloworld"

print(example[::-1].startswith("d"))

a)

dlrowolleh

b)

True

c)

c) -1

d)

None

3.

What will be the output of the “hello” +1+2+3?

a)

hello123

b)

hello

c)

Error

d)

hello6

4.

What will be the output of the following Python code?

print("D", end = ' ')

print("C", end = ' ')

print("B", end = ' ')

print("A", end = ' ')

a)

DCBA

b)

A,B,C,D

c)

D C B A

d)

D

C

B

A

5.

Say s=”hello” what will be the return value of type(s)?

a)

STRING

b)

bool

c)

str

d)

String

6.

What is “Hello”.replace(“l”, “e”)?

a)

Heeeo

b)

Heelo

c)

Heleo

d)

none

7.

What will be the output of the following Python code?

print("abcdef".find("cd") == "cd" in "abcdef")

a)

True

b)

False

c)

error

d)

none

8.

which of the following is incorrect?

a)

String is immutable.

b)

capitalize() function in string is used to return a string by converting the whole given string into uppercase.

c)

lower() function in string is used to return a string by converting the whole given string into lowercase.

d)

None of these

9.

Which of the following will give "Simon" as output?

If str1="John,Simon,Aryan"

a)

print(str1[-7:-12])

b)

print(str1[-11:-7])

c)

print(str1[-11:-6])

d)

print(str1[-7:-11])

10.

What will the below Python code will return?

If str1="save paper,save plants"


print(str1.find("save"))

a)

It returns the first index position of the first occurance of "save" in the given string str1.

b)

It returns the last index position of the last occurance of "save" in the given string str1.

c)

It returns the last index position of the first occurance of "save" in the given string str1.

d)

It returns the first index position of the last occurance of "save" in the given string str1.