WorksheetsQuiz on String
Total questions: 15
Worksheet time: 11mins
What is a string?
A type that represents whole numbers.
Sequences of characters enclosed in a quotation marks
A combination of variables, operators, and values
Int, float and complex
Which one of the following is NOT a string?
a = "12345"
b = Thimphu
c = "Bhutan"
d = 'Thimphu, Bhutan'
Fill in the blank with correct operator to concatenate(join) two strings.
a = "Thimphu "
b = "Bhutan"
c = a _ b
print(c)
(a)
Which of the following statements contain valid Python string literals?
a = "1234"
b = Bhutan
c = 'We're #1!'
d = Hello, World
What’s the value of z after this code snippet executes?
x = "YHSS"
y = "2021"
z = x+y
print(z)
(a)
Guess the correct output of the following String operations:
x = "Welcome"
print(x*2)
WelcomeWelcome
Welcome Welcome
Welcome * 2
Error
What is the index of the last character?
(a)
What is the output of the following code?
x = "Bhutan"
print(x[2])
(a)
What is the output of the following code?
x = "Thimphu, Bhutan"
print(x[:7])
(a)
Strings are immutable in Python, which means a string cannot be modified.
True
False
What is the output of the following program?
var1 = 'Bhutan!'
var2 = "IsACountry"
print ( var1[0], var2[1:5])
B sACo
BsAco
B sACou
BsACou
What is the output of the print() function call?
s = 'Bhu'
t = 'tan'
print('tanB' in 2 * (s + t))
True
False
What is the length of the following strings?
a = "Hello, World!"
print(len(a))
(a)
What is the output of the following program?
a = "Bhutan"
a[0] = "b"
print(a)
Bhutan
bhutan
bBhutan
Error
What is the slice expression that gives you the last three characters of string s?
a[-3:-1]
a[-3:-2]
a[-3:]
a[0:-3]
