Topic 7 - Sequence Types Flashcards
1
Q
In the following code example, what is the backslash doing?
variable = “She said, "Hello!"”
A
The backslash is being used as an escape character. This will allow the double quotes to be printed.
2
Q
What escape character is used to enter a tab?
A
\t
3
Q
How can you stop python from interpreting escape characters?
A
Though the use of raw strings.
A string will need the ‘r’ prefix.
Example:
string = r’line1\nline2’
4
Q
Using a print statement, how would you print a straight line?
A
print(‘_’ * 40)
5
Q
What functions is used to find the length of a string?
A
len