exam questions

Exam PCAP-31-03 All Questions

View all questions & answers for the PCAP-31-03 exam

Exam PCAP-31-03 topic 1 question 82 discussion

Actual exam question from Python Institute's PCAP-31-03
Question #: 82
Topic #: 1
[All PCAP-31-03 Questions]

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

  • A. "python".index("th")
  • B. rfind("python","r")
  • C. "python".sort()
  • D. sorted("python")
Show Suggested Answer Hide Answer
Suggested Answer: AD 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
flthymcnsty
2 months, 1 week ago
Selected Answer: AD
Explanation: The correct answers are: A. "python".index("th") The index() method is used to find the starting index of a substring within a string. "python".index("th") returns 2, as the substring "th" starts at index 2 in the string “python". Example:

result = “python".index("th")
print(result) # Outputs: 2 D. sorted("python") The sorted() function returns a new sorted list containing the characters of the string "python" in alphabetical order. Example:

result = sorted("python")
print(result) # Outputs: ['h', 'n', 'o', 'p', 't', 'y']
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago