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

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

What is the expected output of the following code?

  • A. (2)
  • B. (2,)
  • C. 2
  • D. The code is erroneous.
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, 2 weeks ago
Selected Answer: C
Let's break down the code step by step: data = (1, 2, 4, 8) Here, data is a tuple: (1, 2, 4, 8). data = data[1:-1] This slices the tuple starting from index 1 and ending at index -1. So, it extracts the elements between index 1 and index -1, excluding the element at index -1. The result is: (2, 4). data = data[0] Now, data is a tuple (2, 4). The expression data[0] takes the first element of the tuple, which is 2. print(data) Finally, the code prints the value of data, which is now 2. Therefore, the expected output is: C. 2
upvoted 2 times
...
christostz03
5 months, 2 weeks ago
c is 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