exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 1 question 41 discussion

Actual exam question from Python Institute's PCEP-30-02
Question #: 41
Topic #: 1
[All PCEP-30-02 Questions]

Which one of the lines should you put in the snippet below to match the expected output?
Expected output:

Code:

  • A. sorted(list)
  • B. sort(list)
  • C. list.sort()
  • D. list.sorted()
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
hovnival
2 days, 21 hours ago
Selected Answer: C
To achieve the expected output [1, 2, 4, 7] from the list [2, 7, 1, 4], you should use the list.sort() method, which sorts the list in place. Here is the complete code snippet: Copy list = [2, 7, 1, 4] list.sort() # This sorts the list in place print(list) So, the correct line to use is: C. list.sort()
upvoted 1 times
...
Nfyughguygjhg
3 weeks ago
Selected Answer: A
A is correct
upvoted 1 times
...
rcptryk
1 month, 1 week ago
Selected Answer: C
C is correct because the output expectation must come from print(list) not from the print(sorted(list)). you have to write comment before the print which is list.sort() or you have to write list=sorted(list) which is not option
upvoted 2 times
...
mldprasad
1 month, 1 week ago
Selected Answer: A
list = [2, 7, 1, 4] print(sorted(list)) So A is correct answer. C output is None
upvoted 2 times
...
Vano1
1 month, 4 weeks ago
Selected Answer: C
The correct answer is C. Checked in Python
upvoted 1 times
...
scriptnone
2 months, 1 week ago
Selected Answer: A
list = [2, 7, 1, 4] print(sorted(list)) So A is correct answer. C output is None
upvoted 2 times
...
SujPractise
3 months ago
C will return the sorted list [1, 2, 4, 7]
upvoted 2 times
...
christostz03
4 months, 1 week ago
c is the correct answer
upvoted 2 times
...
Biju1
4 months, 1 week ago
list.sort() will show none
upvoted 2 times
...
Biju1
4 months, 1 week ago
A is correct
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago