Kolmogorov
August 3rd, 2008, 07:18 PM
Hi,
I'm trying to do a nicely formatted table for the following (simple) program:
# chaos.py
def main():
# Introduction
print "This program illustrates a chaotic function."
print
# Get user input
x,y = input("Enter two numbers between 0 and 1 (a,b): ")
n = input("Enter the number of iterations: ")
print
# Create table labels
print "%5s\t%.2f\t%.2f" % ("index",x,y)
print "-" * 35
# Create the table
for i in range(1,n + 1):
x = 3.9 * x * (1 - x)
y = 3.9 * y * (1 - y)
print "%5d\t%.6f\t%.6f" % (i,x,y)
print
main()
* This is actually a problem from the book : "Python Programming: An introduction to computer science" by John Zelle (chapter 4, problem 12).
I want the labels be centered with the values of the table...is there any suggestions ?
Thanks ;)
Kolmogorov
I'm trying to do a nicely formatted table for the following (simple) program:
# chaos.py
def main():
# Introduction
print "This program illustrates a chaotic function."
# Get user input
x,y = input("Enter two numbers between 0 and 1 (a,b): ")
n = input("Enter the number of iterations: ")
# Create table labels
print "%5s\t%.2f\t%.2f" % ("index",x,y)
print "-" * 35
# Create the table
for i in range(1,n + 1):
x = 3.9 * x * (1 - x)
y = 3.9 * y * (1 - y)
print "%5d\t%.6f\t%.6f" % (i,x,y)
main()
* This is actually a problem from the book : "Python Programming: An introduction to computer science" by John Zelle (chapter 4, problem 12).
I want the labels be centered with the values of the table...is there any suggestions ?
Thanks ;)
Kolmogorov