Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



Python & XML    (ISBN: 0596001282)


 

 List Price: $39.95
 Our Price: $27.97
 Used Price: $6.85

 Release Date: 15 December, 2001
 Manufacturer: O'Reilly & Associates (Paperback)
 Sales Rank: 99,783

 Author: Christopher A. Jones, Fred L., Jr. Drake









More Info

 Python Range() 2002-09-28 19:39:47
  python 
Category: source:python:general
Description: An example on using range() to create a number sequence.
Platform: all
Author: mind
Viewed: 5868
Rating: 3.5/5 (12 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
range.py
#!/usr/local/bin/python
#
# range example by mind@metalshell.com
#
# an example on using range() to create a number sequence
#
# 09/25/2002
#
# http://www.metalshell.com
#

print "Example #1 range(5, 10)"
# store a sequence of numbers from 5 to 10 to a
a = range(5, 10)

# print the value..
print "a =", a
print

print "Example #2 range(0, 20, 2)"
# store a sequence of number in increments of 2
a = range(0, 20, 2)

# print the value..
print "a =", a
print

print "Example #3 for s in range(len(a))"
# store a sequence of strings in a
a = ['John', 'Sue', 'Beth', 'Jack']

# use range(), and len() to parse out each segemnt of
# our string sequence..

for s in range(len(a)):
        print 'a[%s] = %s' %(s, a[s])
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?