Return to Snippet

Revision: 67263
at September 1, 2014 08:43 by darylmartens


Updated Code
#Chapter 1 question 7
#Modify the chaos program so that it accepts two inputs and prints a table with two columns.

def main():
    print("This program illustrates a chaotic function")
    x = eval(input("Enter a number between 0 and 1: "))
    y = eval(input("Enter another number between 0 and 1: "))
    n = eval(input("How many rows should I print?: "))
    for i in range(n):
        x = 3.9 * (x - x * x)
        y = 3.9 * (y - y * y)
        print("{0:10.6f} {0:10.6f}" .format(x, y))


main()

Revision: 67262
at September 1, 2014 08:40 by darylmartens


Updated Code
def main():
    print("This program illustrates a chaotic function")
    x = eval(input("Enter a number between 0 and 1: "))
    y = eval(input("Enter another number between 0 and 1: "))
    n = eval(input("How many rows should I print?: "))
    for i in range(n):
        x = 3.9 * (x - x * x)
        y = 3.9 * (y - y * y)
        print("{0:10.6f} {0:10.6f}" .format(x, y))

main()

Revision: 67261
at September 1, 2014 08:39 by darylmartens


Initial Code
def main():
    print("This program illustrates a chaotic function")
    x = eval(input("Enter a number between 0 and 1: "))
    y = eval(input("Enter another number between 0 and 1: "))
    n = eval(input("How many rows should I print?: "))
    for i in range(n):
        x = 3.9 * (x - x * x)
        y = 3.9 * (y - y * y)
        print("{0:10.6f} {0:10.6f}" .format(x, y))
        #print("some text", x, y)


main()

Initial URL


Initial Description
Python Programming - An Introduction to Computer Science: John Zelle

Initial Title
Chapter 1 ex. 7

Initial Tags


Initial Language
Python