-
Notifications
You must be signed in to change notification settings - Fork 9
/
Thursday Feb 12 2015.py
109 lines (65 loc) · 1.08 KB
/
Thursday Feb 12 2015.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
%gui tk
from turtle import *
# <codecell>
reset()
#speed("fastest")
current_color="red"
other_color="black"
for i in range(160):
pencolor(current_color)
forward(150)
backward(150)
left(3)
# comment - swap the colors
if i%3==0:
current_color,other_color=other_color,current_color
# <codecell>
current_color,other_color=other_color,current_color
print "Current: ",current_color
print "Other: ",other_color
# <markdowncell>
# ## Simulation example
# <codecell>
from science import *
# <codecell>
x=2
t=0
constant=10
dt=0.01
# <codecell>
reset()
store(t,x)
for i in range(1000):
dx=constant*dt
x=x+dx
t=t+dt
store(t,x)
# <codecell>
t,x=recall()
# <codecell>
x
# <codecell>
plot(t,x)
# <markdowncell>
# ### second simulation
# <codecell>
x=2
t=0
constant=3
dt=0.01
# <codecell>
reset()
store(t,x)
for i in range(1000):
dx=constant*x*dt
x=x+dx
t=t+dt
store(t,x)
# <codecell>
t,x=recall()
# <codecell>
plot(t,x)
# <codecell>