wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

STRING

Total questions: 13

Worksheet time: 14mins

Name
Class
Date
1.

Which of the following is not correct string?

a)

'Computer'

b)

"Computer"

c)

'''Computer'''

d)

''Computer'

2.

str1="6/4"

print("str1")

a)

6/4

b)

str1

c)

None

3.

str1="python"

Which statement generates an error?

a)

print(str1[2])

b)

str1[1]="x"

c)

print(str1[0:9])

d)

Both (b) and (c)

4.

Which of the following is False?

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

5.

str1="Information"

print(str1[2:8])

a)

format

b)

formatio

c)

orma

d)

ormat

6.

str1="Aplication"

str2=str1.replace('a','A')

print(str2)

a)

application

b)

Application

c)

ApplicAtion

d)

applicAtion

7.

str1="poWer"

str1.upper()

print(str1)

a)

POWER

b)

Power

c)

power

d)

poWer

8.

If str1="save paper,save plants"

str1.find("save")

a)

0

b)

11

c)

None

d)

0,11

9.

s = 'foo'

t = 'bar'

print('barf' in 2 * (s + t))

a)

True

b)

False

c)

None

10.

print(ord('foo'))

What will you get as output?

a)

Error

b)

102

11.

What is the slice expression that gives every third character of string s, starting with the last character and proceeding backward to the first?

(a)  

12.

s = 'foobar'

All of the following expressions produce the same result except one. Which one?

a)

s[::-5]

b)

s[::-1][-1] + s[len(s)-1]

c)

s[0] + s[-1]

d)

s[::-1][::-5]

e)

s[::5]

13.

Which of the following are true:

a)

s[::-1][::-1] == s

b)

s[:] is s

c)

s[::-1][::-1] is s

d)

s[:] == s