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

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

What is the expected output of the following code?

  • A. 1 1 2 3 4 5
  • B. 2 3 4 5 6 1
  • C. 2 3 4 5 6 6
  • D. 1 2 3 4 5 6
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 month, 1 week ago
Selected Answer: C
data = [1, 2, 3, 4, 5, 6] In the first for loop, the code updates each element of data from index 0 to 4 with the value of the next element: for i in range(1, 6): data[i - 1] = data[i] This loop will perform the following assignments: When i = 1: data[0] = data[1] → data = [2, 2, 3, 4, 5, 6] When i = 2: data[1] = data[2] → data = [2, 3, 3, 4, 5, 6] When i = 3: data[2] = data[3] → data = [2, 3, 4, 4, 5, 6] When i = 4: data[3] = data[4] → data = [2, 3, 4, 5, 5, 6] When i = 5: data[4] = data[5] → data = [2, 3, 4, 5, 6, 6] In the second for loop, the code prints each element of data from index 0 to 5: for i in range(0, 6): print(data[i], end=' ') The output of this loop will be: 2 3 4 5 6 6
upvoted 1 times
...
christostz03
5 months, 2 weeks ago
c is the correct answer
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