Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Strings in python -1

Total questions: 22

Worksheet time: 13mins

Name
Class
Date
1.

word = "amazing"

For the given string if we run word[2:5] what does it mean?

a)

It will extract alphabets from index 2 to index 4

b)

It will extract alphabets from index 2 to index 5

c)

It will extract alphabets from position 2 to position 4

d)

It will extract alphabets from position 2 to position 5

2.

Which method is used to convert a given string in Capital letters?

a)

Capital

b)

Upper

c)

ConverttoUpper

d)

Capitalize

3.

Which of the following is not a valid string function?

a)

isalphanumeric

b)

isspace

c)

islower

d)

isalnum

4.

string="HELlo"

What will be the result of string.isupper()?

(a)  

5.

s1="Hello"

n1=10

print(s1+n1)

What is the error in this code?

a)

Print statement not written in quotes

b)

Numeric value not written in quotes

c)

colon not written after the print statement

d)

string cannot be added to a number

6.

In Python, strings are…

a)

char arrays

b)

changeable

c)

immutable

d)

str objects

7.

Which of the following mathematical operators can be used to concatenate strings:

a)

*

b)

/

c)

-

d)

+

8.

what is a string?

a)

any numeric value

b)

any float value

c)

any character value

d)

any special symbol value

9.

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

10.

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

11.

index of a string begins with

a)

1

b)

0

c)

a

d)

-1

12.

slicing string X="BOnVoyage"

print X[0:5]

a)

BOnVoy

b)

BOnVo

c)

oyage

d)

bonvo

13.

a="god help those who help themselves"

"help" in "a"

a)

true

b)

false

c)

wrong out put

d)

error

14.
What is printed?
cheer = "Go Eagles!"
print cheer[1:4]
a)
Go E
b)
o E
c)
"o E"
d)
nothing - there is an error
15.
What is printed?
cheer = "Go Eagles!"
print cheer[0:1]
a)
G
b)
"Go"
c)
Go
d)
o
16.
What is printed?
cheer = "Go Eagles!"
print cheer[5:8]
a)
gle
b)
agle
c)
gles
d)
agles
17.
What is printed?
cheer = "Go Eagles!"
print cheer[7:]
a)
nothing - error
b)
s!
c)
es!
d)
Go Eagles
18.
What is printed?
cheer = "Go Eagles!"
print cheer[:5]
a)
Go Eag
b)
Go Ea
c)
Go E
d)
Go
19.
What is missing in the square braces?
cheer = "Go Eagles!"
print cheer[   ]
If the output is Eagle
a)
[4:9]
b)
[2:8]
c)
[3:7]
d)
[3:8]
20.
What is missing in the square braces?
cheer = "Go Eagles!"
print (cheer[   ] + cheer [  ] + cheer [  ])
If the output is Goggles
a)
0:2    5    5:9
b)
1:2     6   6:10
c)
0:1     5     5:9
d)
0:1     5     5:8
21.

"AB-CD-EF".partition('-') , the function returns the output

a)

('ABCD','-','EF')

b)

('AB', '-', 'CDEF')

c)

('AB', '-', 'CD-EF')

d)

None of the above

22.

Give the output of the following statements

>>> str='Hello World'

>>>str.istiltle()

a)

TRUE

b)

FALSE