Robotics & Artificial Intelligence

Which of the following statement holds valid with Python for loop?

  1. initial value is an optional
  2. stop value is mandatory
  3. step value is an optional
  4. none

Python Control Flow

3 Likes

Answer

stop value is mandatory

Reason — The for loop is a fixed iterative loop where the number of iterations is determined using the range() function. In range(), the initial value and step value are optional because their default values are 0 and 1 respectively, but the stop value is mandatory as it specifies the ending limit of the loop.

Answered By

1 Like


Related Questions