wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Strings in python

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

What is printed by the following statement?

print("P" not in "APCSP")

a)

True

b)

False

c)

Error

2.

Evaluate the following expression:

"dog" < "Dog"

a)

They are the same word

b)

True

c)

False

3.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

4.

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

5.

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

6.

index of a string begins with

a)

1

b)

0

c)

a

d)

-1

7.

________ is used to represent multi line strings.

a)

' '

b)

" "

c)

''' '''

d)

{ }

8.

What will the output be from the following code?

X = "Hello World"

for i in X[0:2]:

print("Bye")

a)

Bye

Bye

b)

Hello World Bye

c)

Bye He

d)

He

Bye

9.

word = "amazing"


For the given string if we run word[2:5] , what would the result be?

a)

mazi

b)

mazin

c)

azi

d)

azin

10.

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

a)

capital

b)

upper

c)

ConverttoUpper

d)

capitalize