Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 86 discussion

Actual exam question from Python Institute's PCAP
Question #: 86
Topic #: 1
[All PCAP Questions]

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

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

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
andr3
Highly Voted 1 year, 8 months ago
hey admin, can you correct those signs to correct signs ?
upvoted 9 times
...
vlobachevsky
Highly Voted 3 years, 1 month ago
BD is correct
upvoted 7 times
...
Damon54
Most Recent 9 months, 3 weeks ago
print ("python".index("t")) 2
upvoted 1 times
...
Damon54
9 months, 3 weeks ago
sorted_string = sorted("python") print(sorted_string) # Stampa: ['h', 'n', 'o', 'p', 't', 'y']
upvoted 1 times
...
zantrz
10 months ago
Selected Answer: BD
sorted() is a general-purpose function that can be used with any iterable, including strings, and it returns a new sorted list. sort() is a method specifically for lists, and it sorts the elements of the list in-place. When dealing with strings, you need to convert them to a list to use sort() and then join the characters back together if needed.
upvoted 2 times
...
seaverick
10 months ago
Selected Answer: BD
#"python".sort()#AttributeError: 'str' object has no attribute 'sort' print(sorted("python")) Ans is B,D #rfind("python","r")#NameError: name 'rfind' is not defined "python".index("th") Ans is A,D
upvoted 1 times
...
seaverick
10 months ago
Selected Answer: AD
#"python".sort()#AttributeError: 'str' object has no attribute 'sort' print(sorted("python")) #rfind("python","r")#NameError: name 'rfind' is not defined "python".index("th") Ans is A,D
upvoted 1 times
...
dcross
1 year ago
Question 86 Which of the following invocations are valid? (Choose two.) respuesta ok B y D A. "python".sort() B. sorted("python") C. rfind("python","r") D. "python".index("th")
upvoted 2 times
...
Jnanada
2 years, 3 months ago
BD is correct
upvoted 2 times
...
stuartz
2 years, 5 months ago
Selected Answer: BD
>>> sorted("python") ['h', 'n', 'o', 'p', 't', 'y'] >>> "python".index("th") 2
upvoted 4 times
...
macxsz
2 years, 6 months ago
Selected Answer: BD
B. sorted("python") D. "python".index("th")
upvoted 5 times
...
Noarmy315
2 years, 10 months ago
BD is correct
upvoted 2 times
...
DTL001
2 years, 11 months ago
The answer is BD
upvoted 2 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 ...