ยปCore Development>Code coverage>Lib/turtledemo/chaos.py

# Python code coverage for Lib/turtledemo/chaos.py

#countcontent
1n/a# File: tdemo_chaos.py
2n/a# Author: Gregor Lingl
3n/a# Date: 2009-06-24
4n/a
5n/a# A demonstration of chaos
6n/a
7n/afrom turtle import *
8n/a
9n/aN = 80
10n/a
12n/a return 3.9*x*(1-x)
13n/a
15n/a return 3.9*(x-x**2)
16n/a
18n/a return 3.9*x-3.9*x*x
19n/a
21n/a penup(); goto(x,y)
22n/a
24n/a jumpto(x1, y1)
25n/a pendown()
26n/a goto(x2, y2)
27n/a
29n/a line(-1, 0, N+1, 0)
30n/a line(0, -0.1, 0, 1.1)
31n/a
33n/a pencolor(color)
34n/a x = start
35n/a jumpto(0, x)
36n/a pendown()
37n/a dot(5)
38n/a for i in range(N):
39n/a x=fun(x)
40n/a goto(i+1,x)
41n/a dot(5)
42n/a
44n/a reset()
45n/a setworldcoordinates(-1.0,-0.1, N+1, 1.1)
46n/a speed(0)
47n/a hideturtle()
48n/a coosys()
49n/a plot(f, 0.35, "blue")
50n/a plot(g, 0.35, "green")
51n/a plot(h, 0.35, "red")
52n/a # Now zoom in:
53n/a for s in range(100):
54n/a setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
55n/a return "Done!"
56n/a
57n/aif __name__ == "__main__":
58n/a main()
59n/a mainloop()