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

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

What is the expected output of the following code?

  • A. ['1', '2', '3', '4']
  • B. (1, 2, 3, 4)
  • C. ('1', '2', '3', '4')
  • 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
The expected output of the given code is: C. ('1', '2', '3', '4') Explanation: data1 = '1', '2': This is a tuple assignment. In Python, writing values separated by commas without parentheses creates a tuple. So, data1 becomes ('1', '2'). data2 = ('3', '4'): This explicitly creates a tuple with parentheses. So, data2 becomes ('3', '4'). data1 + data2: The + operator concatenates two tuples. So, ('1', '2') + ('3', '4') results in ('1', '2', '3', '4'). print(data1 + data2): This prints the concatenated tuple ('1', '2', '3', '4'). Hence, the correct answer is C.
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