| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
| import time
import math
import Tkinter
winheight = 600
winwidth = 800
win = Tkinter.Tk()
can = Tkinter.Canvas(win, height = winheight, width = winwidth, background = "white")
can.pack()
xstep = 20
ystep = 5
can.create_line(10, 10, 10, winheight-10, width=3, fill="black")
can.create_line(10, winheight-10, winwidth-10, winheight-10, width=3, fill="black")
for i in range(10, winheight-10):
if i % 20*ystep == 0:
can.create_line(8, i, 12, i, width=3, fill="black")
for i in range(10, winwidth-10):
if i %20* xstep == 0:
can.create_line(i, winheight-8, i, winheight-12, width=3, fill="black")
N = 1.0
L = 1.1
K = 80.0
for t in range(50):
oldN = N
N *= L
if N < 0.0:
N = 0.0
N+= oldN
print N
can.create_rectangle(8+t*xstep, winheight-8-N*ystep, 14+t*xstep, winheight-14-N*ystep, width=0, fill="green")
if t > 0:
can.create_line(10+(t-1)*xstep, winheight-10-oldN*ystep, 10+t*xstep, winheight-10-N*ystep, width=2, fill="blue")
can.update()
time.sleep(0.5)
can.mainloop()
#####################################
import time
import math
import Tkinter
winheight = 600
winwidth = 800
win = Tkinter.Tk()
can = Tkinter.Canvas(win, height = winheight, width = winwidth, background = "white")
can.pack()
xstep = 10
ystep = 5
can.create_line(10, 10, 10, winheight-10, width=3, fill="black")
can.create_line(10, winheight-10, winwidth-10, winheight-10, width=3, fill="black")
for i in range(10, winheight-10):
if i % 20*ystep == 0:
can.create_line(8, i, 12, i, width=3, fill="black")
for i in range(10, winwidth-10):
if i %20* xstep == 0:
can.create_line(i, winheight-8, i, winheight-12, width=3, fill="black")
N = 1.0
K = 80.0
L = input("Enter growth rate. ")
for t in range(50):
oldN = N
N *= L*(1.0-(N/K))
if N < 0.0:
N = 0.0
N+= oldN
print N
can.create_rectangle(8+t*xstep, winheight-8-N*ystep, 14+t*xstep, winheight-14-N*ystep, width=0, fill="green")
if t > 0:
can.create_line(10+(t-1)*xstep, winheight-10-oldN*ystep, 10+t*xstep, winheight-10-N*ystep, width=2, fill="blue")
can.update()
time.sleep(0.5)
can.mainloop() |