exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 7 question 28 discussion

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

What is the expected output of the following code?

  • A. 6
  • B. The code is erroneous.
  • C. 9
  • D. 3
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
Donny_575
3 weeks, 3 days ago
Selected Answer: D
D. 3 Explanation: data = [1, 2, [3, 4], [5, 6], 7, [8, 9]] You are looping through the list data and counting how many elements are lists. The list has 6 elements: 1, 2, 7 count as 3 elements, while [3, 4], [5, 6], [8, 9] count as an additional 3 count only increases if an element is a list 1, 2, 7 are not lists [3, 4], [5, 6], [8, 9] are lists, so count = 3
upvoted 1 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