The range() function returns a sequence of numbers, starting from 0 by default, increments by 1 (by default), and stops before a specified number.
It is commonly used with for loops to iterate a specific number of times.
range()The range() function can take up to three arguments:
range(start, stop, step)
start (Optional): An integer specifying at which position to start. Default is 0.stop (Required): An integer specifying at which position to stop (not included).step (Optional): An integer specifying the incrementation. Default is 1.stop ParameterIf you only pass one argument to range(), it will treat it as the stop value. The sequence will start at 0.
# Generates numbers from 0 to 4 (5 is not included) for x in range(5): print(x)
start and stop ParametersIf you pass two arguments, the first is the start value and the second is the stop value.
# Starts at 2, stops at 5 (6 is not included) for x in range(2, 6): print(x)
step ParameterIf you want the sequence to increment by a different number (like 2, 5, or even negative numbers), you can provide a third argument.
# Starts at 2, stops before 20, increments by 3 for x in range(2, 20, 3): print(x)
What will range(1, 4) produce?