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

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

Take a look at the snippet, and choose the true statements: (Choose two.)

  • A. nums is longer than vals
  • B. nums and vals are of the same length
  • C. vals is longer than nums
  • D. nums and vals refer to the same list
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️

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 month, 2 weeks ago
Selected Answer: BD
Let's analyze the code snippet step by step: nums = [1, 2, 3] Creates a list nums with three elements: [1, 2, 3]. vals = nums The variable vals is assigned the same reference as nums. Now both vals and nums point to the same list object in memory. del vals[1:2] The slice vals[1:2] selects the element at index 1 (value 2). The del statement removes this element from the list. Since vals and nums point to the same list, the change affects both. After this operation, the list becomes [1, 3]. Now evaluate the options: A. nums is longer than vals False. Both nums and vals refer to the same list, which now has a length of 2. B. nums and vals are of the same length True. Both nums and vals are the same list, so their lengths are equal. C. vals is longer than nums False. Both nums and vals refer to the same list. D. nums and vals refer to the same list True. nums and vals point to the same memory location, so they refer to the same list. Correct Answers: B. nums and vals are of the same length D. nums and vals refer to the same list
upvoted 2 times
...
christostz03
5 months, 2 weeks ago
b & d are correct answers
upvoted 1 times
...
froster02
6 months, 3 weeks ago
vals = nums -> this statement means both the Vals & nums will share same memory pool vals = noms[:] -> this means both have different memory pool
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