Python_Institute
PCEP-30-02 · Question #310
Which of the following sentences correctly describes the output of the below Python code? ``python data = [4, 2, 3, 2, 1] res = data[0] for d in data: if d < res: res = d print(res) ``
The correct answer is C. res is the smallest number in the list. See the full explanation below for the reasoning.
Question
Which of the following sentences correctly describes the output of the below Python code?
data = [4, 2, 3, 2, 1]
res = data[0]
for d in data:
if d < res:
res = d
print(res)
Options
- ANone of the above.
- Bres is the sum of all the number in the list.
- Cres is the smallest number in the list.
- Dres is the largest number in the list.
- Eres is the average of all the number in the list.
How the community answered
(53 responses)- A2% (1)
- B6% (3)
- C81% (43)
- D9% (5)
- E2% (1)
Community Discussion
No community discussion yet for this question.