mile/kilometer conversion : range « Buildin Function « Python Tutorial






for miles in range(10, 70, 10):
    km = miles * 1.609
    print "%d miles --> %3.2f kilometers" % (miles, km)








13.38.range
13.38.1.A built-in function to make ranges for you
13.38.2.The given end point is never part of the generated list
13.38.3.specify a different increment (even negative)
13.38.4.writes out the numbers from 1 to 100
13.38.5.uses the range() function to create a temporary sequence of integers the size of a list
13.38.6.Simple Counters based on range function
13.38.7.For each item in a range
13.38.8.List Comprehensions
13.38.9.select what to include in the new list
13.38.10.range(): range(start, end, step=1)
13.38.11.range(end), range(start, end)
13.38.12.mile/kilometer conversion
13.38.13.list-copy function using range()