PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 138


Which of the following invocations are valid? (Choose two.)

Show Answer
Correct Answer: BC

The question asks which of the following invocations are valid. Option B is valid because the find() method is a built-in string method in Python that searches for a specified substring within the string. Option C is also valid because the rindex() method is another built-in string method that returns the highest index of a specified substring within the string. Options A and D are invalid: Option A attempts to use a sort function incorrectly on a string, and Option D incorrectly tries to use the sorted() method on a string, which should be used on iterables like lists, but not strings.

Discussion

2 comments
Sign in to comment
macxszOptions: BC
May 4, 2022

The only correct statements: B. "python".find("") C. "python".rindex("th")

andr3Options: AB
Mar 17, 2023

can admin edit the Q with correct signs ? A. sort(ג€pythonג€) B. ג€pythonג€.find(ג€ג€) C. ג€pythonג€.rindex(ג€thג€) D. 'python'.sorted()