PCEP-30-02 Practice Test

PCEP-30-02 Practice Test practice questions, page 9 of 20, with answer review and explanations.

Question 41

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

  1. sorted(list)
  2. sort(list)
  3. list.sort()
  4. list.sorted()

Question 42

Which of the following sentences are true about the code? (Choose two.)

  1. nums and vals are different lists
  2. vals is longer than nums
  3. nums and vals are different names of the same list
  4. nums and vals have the same length

Question 43

The second assignment:

  1. extends the list
  2. doesn't change the list's length
  3. shortens the list

Question 44

What is the expected output of the following code?

  1. efg
  2. abc
  3. def
  4. The code is erroneous.
  5. abcde
  6. None of the above.

Question 45

Which function does in-place reversal of objects in a list?

  1. list.sort([func])
  2. list.pop(obj=list[-1])
  3. list.remove(obj)
  4. list.reverse()