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 57 discussion

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

What is the output of the following snippet?

  • A. [0, 1, 9, 16]
  • B. [0, 1, 4, 16]
  • C. [0, 1, 4, 9]
  • D. [1, 4, 9, 16]
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
1 day, 22 hours ago
Selected Answer: C
Let's analyze the given code snippet step-by-step to determine the output: my_list = [x * x for x in range(5)] This creates a list comprehension that generates a list of the squares of numbers from 0 to 4. The resulting list is [0, 1, 4, 9, 16]. The function fun takes a list lst as an argument. del lst[lst[2]] removes the element at the index specified by the value of lst[2]. In my_list, lst[2] is 4. Therefore, del lst[4] removes the element at index 4 from the list lst. The list lst is modified in place and then returned. print(fun(my_list)) This calls the function fun with my_list as the argument and prints the result. Let's see the steps within the function fun: The initial list is [0, 1, 4, 9, 16]. lst[2] is 4, so del lst[4] removes the element at index 4, which is 16. The modified list is [0, 1, 4, 9]. Therefore, the expected output of the code is: [0, 1, 4, 9]
upvoted 1 times
...
christostz03
4 months, 1 week ago
c is the correct answer
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