Certified Associate in Python Programming (PCAP-31-03) — Question 79
Which of the following invocations are valid? (Choose two.)
Answer options
- A. 'python'.sorted()
- B. "python".rindex("th")
- C. sort("python")
- D. "python".find("")
Correct answer: B, D
Explanation
Option B is correct because the rindex method is used to find the highest index of a substring within a string, which is valid. Option D is also correct because the find method is used to locate a substring, and calling it with an empty string returns 0. Options A and C are incorrect as 'python'.sorted() is not a valid method for strings, and sort('python') is not a valid function call in this context.