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.
#"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
#"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
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")
This section is not available anymore. Please use the main Exam Page.PCAP Exam Questions
Log in to ExamTopics
Sign in:
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.
andr3
Highly Voted 2 years, 1 month agovlobachevsky
Highly Voted 3 years, 7 months agoDamon54
Most Recent 1 year, 3 months agoDamon54
1 year, 3 months agozantrz
1 year, 3 months agoseaverick
1 year, 3 months agoseaverick
1 year, 3 months agodcross
1 year, 5 months agoJnanada
2 years, 8 months agostuartz
2 years, 10 months agomacxsz
3 years agoNoarmy315
3 years, 3 months agoDTL001
3 years, 4 months ago