Python Range Exercises

Let’s check out some exercises that will help understand range() function better.

Exercise 14-a

Create a range from 0 to 50, excluding 50.


range() function can be used to create range type data.

rng = range (50)
or rng = range(0,50)

Exercise 14-b

Create a range from 0 to 10 with steps of 2.


range() function can take 3 parameters. range(start, stop, step)

rng = range(0,10,2)