Page 69 - Modular v1.1 Pyhton
P. 69
Recap
A sequence of characters which is enclosed or surrounded by single (' ') or double (" ") quotes
is known as a string.
Escape sequences or characters are used to insert special characters that are invalid in Python.
Traversing means visiting each element and processing it as required by the program.
Concatenating, replicating, membership (in /not in), comparison and slicing are various
operations that can be performed on a string.
To modify and manipulate strings, Python provides several built-in (pre-defined) functions.
Exercise
A. Tick ( ) the correct option.
1. Which of the following is used to insert special characters that are invalid in Python?
a. Escape sequence b. Indentation
c. Lists d. None of the above
2. Which operator is used to repeat the string for a given number of times?
a. String concatenation operator b. String replication operator
c. len( ) d. None of the above
3. Which of the following does string include?
a. Letter b. Number
c. Special characters d. All of the above
4. Which of the following is correct about multiline string?
a. It begins and ends with either single quotes or single double quotes
b. It begins and ends with either double single quotes or double quotes
c. It begins and ends with either three triple quotes or three double quotes
d. It begins and ends with either three single quotes or three double quotes
5. Which of the following string function calculates and returns the length of a string supplied as
an argument?
a. len( ) b. lower( )
c. upper( ) d. capitalize( )
B. Write 'T' for true and 'F' for false.
1. Escape sequences are used to delete special characters. ……………………
2. Strings can be created by enclosing characters inside single or double quotes. ……………………
3. Traversing means visiting each element and processing it as required by
the program. ……………………
4. Index with positive integer’s starts from left with 1. ……………………
5. Python uses + for concatenation and * for replication. ……………………
String Handling in Python 67

