Podcast
Questions and Answers
What is the purpose of the str.capitalize()
method?
What is the purpose of the str.capitalize()
method?
- It capitalizes the first letter of each word in the string.
- It returns a copy of the string with the first letter uppercase and the rest lowercase. (correct)
- It returns a copy of the string with all letters capitalized.
- It modifies the original string by capitalizing the first letter and lowercasing the rest.
Which of the following best describes the behavior of the str.count(s)
method?
Which of the following best describes the behavior of the str.count(s)
method?
- It returns the number of times the substring `s` appears in the string, including overlapping occurrences.
- It returns the total number of characters in the string.
- It returns the index of the first occurrence of the substring `s` in the string.
- It returns the number of non-overlapping occurrences of the substring `s` in the string. (correct)
What is the purpose of the str.endswith(end)
method?
What is the purpose of the str.endswith(end)
method?
- It returns `True` if the string ends with the characters in the `end` string, and `False` otherwise. (correct)
- It removes the characters in the `end` string from the end of the string.
- It checks if the string contains the characters in the `end` string, regardless of their position.
- It returns `True` if the string starts with the characters in the `end` string, and `False` otherwise.
What does the str.find(s, beg, end)
method do?
What does the str.find(s, beg, end)
method do?
What is the purpose of the str.format(*expressions)
method?
What is the purpose of the str.format(*expressions)
method?
Which of the following is true about the str.find(s)
method?
Which of the following is true about the str.find(s)
method?
What is the difference between str.find(s)
and str.find(s, beg)
?
What is the difference between str.find(s)
and str.find(s, beg)
?