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

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

How many stars will the following snippet print to the monitor?

  • A. three
  • B. zero
  • C. two
  • D. one
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
4ba36e7
1 month, 3 weeks ago
Selected Answer: C
Outer loop: for y in range(3) → y = 0, 1, 2 y = 0: [x for x in range(0)] → [] (empty list) y = 1: [x for x in range(1)] → [0] y = 2: [x for x in range(2)] → [0, 1] data = [ [], # len = 0 [0], # len = 1 [0, 1] # len = 2 ] for d in data: if len(d) < 2: print('*') d = [] → length 0 < 2 → prints * d = [0] → length 1 < 2 → prints * d = [0, 1] → length 2 < 2 → false, no print C. two
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 ...