Posted By

darylmartens on 09/01/14


Tagged


Versions (?)

Chapter 1 ex. 7


 / Published in: Python
 

Python Programming - An Introduction to Computer Science: John Zelle

  1. #Chapter 1 question 7
  2. #Modify the chaos program so that it accepts two inputs and prints a table with two columns.
  3.  
  4. def main():
  5. print("This program illustrates a chaotic function")
  6. x = eval(input("Enter a number between 0 and 1: "))
  7. y = eval(input("Enter another number between 0 and 1: "))
  8. n = eval(input("How many rows should I print?: "))
  9. for i in range(n):
  10. x = 3.9 * (x - x * x)
  11. y = 3.9 * (y - y * y)
  12. print("{0:10.6f} {0:10.6f}" .format(x, y))
  13.  
  14.  
  15. main()

Report this snippet  

You need to login to post a comment.