Certified Associate in Python Programming (PCAP-31-03) — Question 78

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

Answer options

Correct answer: A, D

Explanation

The invocation in option A is valid as it uses the index method to find the position of 'th' in 'python'. Option D is also valid because the sorted function can be applied to a string to return a sorted list of its characters. Options B and C are incorrect; B has the wrong syntax as rfind is not called on a string object, and C fails since strings do not have a sort method.