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

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

What is the expected output of the following code?

  • A. 4
  • B. 10
  • C. Nothing gets printed.
  • D. The code is erroneous.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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 day, 23 hours ago
Selected Answer: B
The given code concatenates two tuples data1 and data2 to form a new tuple and then sums up its elements. Here is the step-by-step explanation: data1 = (1, 2) data2 = (3, 4) The expression data1 + data2 concatenates the two tuples to form a single tuple (1, 2, 3, 4). The list comprehension [print(sum(x)) for x in [data1 + data2]] iterates over a list containing the single concatenated tuple [(1, 2, 3, 4)]. So, the list comprehension will execute print(sum((1, 2, 3, 4))). The sum function calculates the sum of the elements in the tuple (1, 2, 3, 4), which is 1 + 2 + 3 + 4 = 10. The print function prints the result 10. Therefore, the expected output of the code is: 10
upvoted 1 times
...
christostz03
4 months, 1 week ago
b 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