Tuesday, November 24, 2020

, , ,

Use of Range Function In Python With Program

 python range function in python return the sequence of numbers between the start integer value to the stop integer.

Syntax : -

range(stop)
range(start, stop[, step])

Parameters For range() function in python:-

Range function takes the three arguments which is given below :-

  •  first one is a start point which define the starting point of range function.
  • second one is stop point integer which help to tell the end point for the sequence.
  • Step is a third one and it use to define the increment for the sequence of number.

Return value from range function in python: -

  •  range() function return the immutable sequence of number.
  • In this function sequence of number starts form 0 to Stop-1.
  • if the step argument is then it raise an Value Error.

How to use the range function in python with program

# empty range
print(list(range(0)))

# using range(stop)
print(list(range(10)))

# using range(start, stop)
print(list(range(1, 10)))

Output:

range function program in python
range function program in python


0 comments:

Post a Comment