Skip to content

Commit f1fdbc5

Browse files
Updated coupled spring notebook for python 3
This is updated for python 3 since most notebooks usually run on Google Colab, which automatically runs on python 3
1 parent 5e2833a commit f1fdbc5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ipython/CoupledSpringMassSystem.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"with open('two_springs.dat', 'w') as f:\n",
163163
" # Print & save the solution.\n",
164164
" for t1, w1 in zip(t, wsol):\n",
165-
" print >> f, t1, w1[0], w1[1], w1[2], w1[3]"
165+
" print(t1, w1[0], w1[1], w1[2], w1[3], file=f)"
166166
],
167167
"language": "python",
168168
"metadata": {},
@@ -183,15 +183,14 @@
183183
"# Plot the solution that was generated\n",
184184
"\n",
185185
"from numpy import loadtxt\n",
186-
"from pylab import figure, plot, xlabel, grid, hold, legend, title, savefig\n",
186+
"from pylab import figure, plot, xlabel, grid, legend, title, savefig\n",
187187
"from matplotlib.font_manager import FontProperties\n",
188188
"\n",
189189
"t, x1, xy, x2, y2 = loadtxt('two_springs.dat', unpack=True)\n",
190190
"\n",
191191
"figure(1, figsize=(6, 4.5))\n",
192192
"\n",
193193
"xlabel('t')\n",
194-
"grid(True)\n",
195194
"hold(True)\n",
196195
"lw = 1\n",
197196
"\n",
@@ -220,4 +219,4 @@
220219
"metadata": {}
221220
}
222221
]
223-
}
222+
}

0 commit comments

Comments
 (0)