Python - Print a range of numbers
Python - Print a range of numbers
CODE
#This function accepts 2 parameters. The Starting Number and the Ending Number.
def writeNumbers(start, end):
#The variable i is initialized with the Starting Number.
i = start
#The loop handles the printing of numbers from the starting number to the ending number.
while(i <= end):
print(i)
#The variable i is incremented by 1 in order to move to the next number in the next iteration.
i = i + 1
#This statement invokes the above function.
#The starting number and ending number are supplied here. This can be supplied even from the command line.
writeNumbers(5,10);
#OUTPUT:
#5
#6
#7
#8
#9
#10
Comments
Post a Comment