Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz on String

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

What is a string?

a)

A type that represents whole numbers.

b)

Sequences of characters enclosed in a quotation marks

c)

A combination of variables, operators, and values

d)

Int, float and complex

2.

Which one of the following is NOT a string?

a)

a = "12345"

b)

b = Thimphu

c)

c = "Bhutan"

d)

d = 'Thimphu, Bhutan'

3.

Fill in the blank with correct operator to concatenate(join) two strings.

a = "Thimphu "

b = "Bhutan"

c = a _ b

print(c)

(a)  

4.

Which of the following statements contain valid Python string literals?

a)

a = "1234"

b)

b = Bhutan

c)

c = 'We're #1!'

d)

d = Hello, World

5.

What’s the value of z after this code snippet executes?

x = "YHSS"

y = "2021"

z = x+y

print(z)

(a)  

6.

Guess the correct output of the following String operations:

x = "Welcome"

print(x*2)

a)

WelcomeWelcome

b)

Welcome Welcome

c)

Welcome * 2

d)

Error

7.

What is the index of the last character?

(a)  

8.

What is the output of the following code?

x = "Bhutan"

print(x[2])

(a)  

9.

What is the output of the following code?

x = "Thimphu, Bhutan"

print(x[:7])

(a)  

10.

Strings are immutable in Python, which means a string cannot be modified.

a)

True

b)

False

11.

What is the output of the following program?

var1 = 'Bhutan!'

var2 = "IsACountry"


print ( var1[0], var2[1:5])

a)

B sACo

b)

BsAco

c)

B sACou

d)

BsACou

12.

What is the output of the print() function call?

s = 'Bhu'

t = 'tan'

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

a)

True

b)

False

13.

What is the length of the following strings?

a = "Hello, World!"

print(len(a))

(a)  

14.

What is the output of the following program?

a = "Bhutan"

a[0] = "b"

print(a)

a)

Bhutan

b)

bhutan

c)

bBhutan

d)

Error

15.

What is the slice expression that gives you the last three characters of string s?

a)

a[-3:-1]

b)

a[-3:-2]

c)

a[-3:]

d)

a[0:-3]