# ArrayDemo.py (c) Kari Laitinen
# http://www.naturalprogramming.com
# 2006-04-07 File created.
# 2006-05-27 Latest modification.
# The corresponding Java/C++/C# programs demonstrate the use of a
# traditional array. This program demonstrates the use of a list,
# which is a kind of dynamic array in Python.
# A list can be defined by giving its values inside brackets [ ]
# Lists can be concatenated by using the operator +
# Lists can be indexed by giving an index expression inside brackets
# after the list name. In this sense lists are like arrays of other
# programming languages.
# See also program \pythonfilesextra\ArrayDemoEfficient.py
integer_index = 0
list_of_integers = [ 333 ]
list_of_integers = list_of_integers + [ 33 ]
list_of_integers = list_of_integers + [ 3 ]
list_of_integers = list_of_integers + [ list_of_integers[ 2 ] + 2 ]
for integer_index in range( 4, 50 ) :
list_of_integers = list_of_integers + \
[ list_of_integers[ integer_index - 1 ] + 2 ]
print "\n The contents of \"list_of_integers\" is:"
for integer_index in range( 50 ) :
if ( ( integer_index % 10 ) == 0 ) :
print # This prints an empty line.
print "%5d" % list_of_integers[ integer_index ],