Hello friends, lets learn about range function in Python3.
The range function generates arithmetic progression.
Syntax of range function:
range (start_num, end_num, step)
For example:
range(0,10,2)
It will start at 0 and will increment by 2, the last no printed will be 8.
The output will be: 0 2 4 6 8
Check out this program:
The range function generates arithmetic progression.
Syntax of range function:
range (start_num, end_num, step)
For example:
range(0,10,2)
It will start at 0 and will increment by 2, the last no printed will be 8.
The output will be: 0 2 4 6 8
Check out this program:
print ("Using range function...")
# xrange in Python 2.7
# range built in function
for x in range(1,11):
print (x)
# prints from 1 --> 10
Output |