Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
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 4 discussion

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

What is the expected output of the following code?

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

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
consultsk
1 month ago
Selected Answer: C
The code performs the following steps: 1. `list1 = [1, 3]`: Initializes `list1` with the elements `[1, 3]`. 2. `list2 = list1`: Assigns `list2` to refer to the same list object as `list1`. Now both `list1` and `list2` refer to the same list in memory. 3. `list1[0] = 4`: Modifies the first element of `list1` to be `4`. Since `list2` refers to the same list, this modification is reflected in `list2` as well. 4. `print(list2)`: Prints `list2`. Since `list2` refers to the same list as `list1`, after modifying `list1`, `list2` will also reflect the changes. **Expected output:** `[4, 3]`
upvoted 1 times
...
megan_mai
2 months, 1 week ago
Selected Answer: C
After assigning list2 = list 1 >> both refer to the same list in memory >> changing list1 value will affect list2 value >> answer is [4,3]
upvoted 1 times
...
christostz03
2 months, 1 week ago
c is the correct answer
upvoted 1 times
...
herrmann69
4 months, 4 weeks ago
Selected Answer: C
C is correct. list1 and list2 point to the same location in memory.
upvoted 3 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 ...