Python Range() function - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python Range() function - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Thursday, December 6, 2018

Python Range() function

Python Range() function




The range() function

You can use the range() function to work with a set of numbers efficiently. The range() function starts at 0 by defalut, and stops one number below the number passed to it. You can use the list() function to efficiently generate a large list of numbers.

#Printing the numbers 0 to 1000
for number in range (1001):
  print(number)
#Printing the number 1 to 1000
for number in range(1, 1001):
   print(number)
#Making a list of numbers from 1 to a million
numbers = list(range(1, 1000001))

Screenshot 

 
python range

No comments:

Post a Comment

Post Top Ad