Page 78 - tp_Modula_v2.0
P. 78
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. ……………………
C. Fill in the blanks using the words given below:
escape, lowercase, capitalize(), right, concatenation
1. Index with negative integers starts from …………………… with -1.
2. The backslash (\) is a special character and is also known as the …………………… character.
3. String …………………… operator joins two or more strings into one.
4. The lower() function converts all uppercase letters to …………………….
5. The …………………… function returns a string with the first character in capital.
D. Short answer type questions.
1. What are strings?
2. What is the difference between (+) and (*)?
3. What do you mean by traversing a string?
E. Long answer type questions.
1. Explain different ways of indexing a list.
2. Write any two built-in functions to manipulate strings.
3. What do you mean by escape sequences? Explain in detail.
Critical Thinking
F. What will be the output of the following?
test_str = "Good Morning"
print("The original string is : " + str(test_str))
hlf_idx = len(test_str)
res = ' '
for idx in range(len(test_str)):
if idx >= hlf_idx:
76 Touchpad MODULAR (Version 2.0)

