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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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: AD 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
andr3
Highly Voted 1 year, 1 month ago
hey admin, can you correct those signs to correct signs ?
upvoted 8 times
...
vlobachevsky
Highly Voted 2 years, 6 months ago
BD is correct
upvoted 7 times
...
Damon54
Most Recent 2 months, 1 week ago
print ("python".index("t")) 2
upvoted 1 times
...
Damon54
2 months, 1 week ago
sorted_string = sorted("python") print(sorted_string) # Stampa: ['h', 'n', 'o', 'p', 't', 'y']
upvoted 1 times
...
zantrz
2 months, 2 weeks 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
2 months, 3 weeks 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
2 months, 3 weeks 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
5 months 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
1 year, 8 months ago
BD is correct
upvoted 2 times
...
stuartz
1 year, 10 months ago
Selected Answer: BD
>>> sorted("python") ['h', 'n', 'o', 'p', 't', 'y'] >>> "python".index("th") 2
upvoted 4 times
...
macxsz
1 year, 11 months ago
Selected Answer: BD
B. sorted("python") D. "python".index("th")
upvoted 5 times
...
Noarmy315
2 years, 3 months ago
BD is correct
upvoted 2 times
...
DTL001
2 years, 4 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 ...