Chapter 10 String Manuplation
Chapter 10 String Manuplation
Instructions:
Answer all questions.
Read each question carefully before attempting.
For MCQ questions, choose the most appropriate answer and write the corresponding letter (A, B, C, or D) in the
answer sheet.
For programming questions, use meaningful variable names.
Comments are appreciated but not mandatory.
Marks are indicated for each question.
Questions:
1|Page
7. Which string method removes leading and trailing whitespace from a string?
A) strip()
B) replace()
C) split()
D) join()
9. Which string method returns the index of the first occurrence of a specified substring within a string?
A) find()
B) count()
C) replace()
D) split()
11. String concatenation in Python can be achieved using the '+' operator.
12. The len() function in Python returns the number of characters in a string, including spaces.
13. String indexing in Python is zero-based, meaning the first character in a string has an index of 1.
14. The find() method in Python returns the index of the first occurrence of a substring within a string. If the
substring is not found, it returns -1.
15. Strings in Python are immutable, meaning they cannot be changed after they are created.
True
Part C: Programming Questions (30 Marks)
20. Write a Python function named count_vowels that takes a string as input and returns the number of vowels
('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') present in the string.
2|Page