PCEP 30 02 PCEP Certified Entry Level Python Programmer · Free Practice Question Medium

Question 15

What is the output of the following code snippet?


  • A

    ['Pagani', 'Ferrari', 'Aston', 'Lamborghini', 'McLaren']

  • B

    ['Ferrari', 'Aston', 'Lamborghini', 'Pagani', 'Pagani']

  • C

    ['McLaren', ['Ferrari', 'Aston', 'Lamborghini'], 'McLaren']

  • D

    ['Ferrari', 'Aston', 'Lamborghini', 'Pagani', 'McLaren']

Reveal correct answer

Correct answer: D

Explanation

First, cars_disp() is called and "Pagani" is added after the last element of ["Ferrari","Aston", "Lamborghini"] so it is ["Ferrari","Aston", "Lamborghini", "Pagani"]


Again, cars_disp() is called and "McLaren" is added after the last element of ["Ferrari","Aston", "Lamborghini", "Pagani"] so it is ["Ferrari","Aston", "Lamborghini", "Pagani", "McLaren"]

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need