nerdexam
Cisco

350-401 · Question #942

Refer to the exhibit. What is output by this code?

The correct answer is C. 0 1 2 3 4. The Python range(5) function generates a sequence of numbers starting from 0 up to, but not including, the specified argument, which are then printed by the loop.

Submitted by tyler.j· Mar 6, 2026Automation and Programmability

Question

Refer to the exhibit. What is output by this code?

Options

  • A0 5
  • B0 1 2 3 4 5
  • C0 1 2 3 4
  • D(0,5)

How the community answered

(21 responses)
  • A
    5% (1)
  • B
    10% (2)
  • C
    71% (15)
  • D
    14% (3)

Why each option

The Python `range(5)` function generates a sequence of numbers starting from 0 up to, but not including, the specified argument, which are then printed by the loop.

A0 5

This output is incorrect because `range(5)` generates multiple values, not just 0 and 5.

B0 1 2 3 4 5

This output is incorrect because `range(5)` excludes the stop value (5), so 5 itself is not printed.

C0 1 2 3 4Correct

The `range(5)` function generates the sequence `0, 1, 2, 3, 4`. The `for` loop iterates through these values, and the `print(i)` statement displays each number on a new line.

D(0,5)

This output is incorrect because `range(5)` generates individual numbers, and the print statement displays them one by one, not as a tuple.

Concept tested: Python `range()` function and `for` loop

Source: https://docs.python.org/3/library/stdtypes.html#range

Topics

#Code execution tracing#Looping constructs#Scripting output prediction

Community Discussion

No community discussion yet for this question.

Full 350-401 Practice