Are you ready?
1 questions to solve.
- This quiz goes to full-screen once you press the Start button.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
1. True or false?
0, and Python is no exception. For more details, please refer to Python String Basics.
'Hello'is a string literal. True or false?
s = 'Hello'
"Hello"are identical to each other. Yes or no?
"Hello"are defined in different ways — one using single quotes and the other using double quotes — however they denote exactly the same piece of information. In other words, they are identical to each other.
s = 'Python's call!'
s, which is defined using
'(single quotes), contains a single quote itself. This can be rectified by either escaping this quote character using a backslash or by simply using a multiline string. Hence, the correct choice is (D).
For more specific details, please refer to Python String Basics — escaping characters and Python String Basics — multiline strings.
'''Hello World!''') or triple-double-quotes (
"""Hello World!"""). Hence, the correct choice here is (C). For more details on multiline strings, refer to Python String Basics — multiline strings.
s, a given character can be accessed via bracket notation — putting the index of the desired character within the pair of brackets. To access the second character, for example, we'll write
s. Hence, the correct choice is (C).
len()function in Python returns the numbers of characters in it. In this case, it returns
6, and this goes with choice (B).
scan be accessed directly using
s[-1], or by using
s[len(s) - 1], realising the fact that the last character is at an index one lesser than the length of the string. This goes with choice (D).
s = 'Hello' print(s[1:3])
s[1:3]slices the string
1exactly upto index
3, since it is exclusive), to yield the substring
'el'. The correct choice is, therefore, (A). Read more at Python String Basics — slicing a string.
*operator, when used on string, replicates the strings a given number of times. Read more details at Python String Basics — string replication.
rare commonly known as raw strings. They prevent the need to escape backslashes — just write them, as is. To learn more about them, refer to Python String Basics — raw strings.
r'Hello\\World'evaluate down to?