> > https://www.youtube.com/watch?v=fKthpFIV-TU > > Way cool.
I made some notes: I like how you muddle your way through, showing where you're getting confused. Students looking over your shoulder want to help. Not intimidating. Shows how we're meant to explore, even as teachers. You get confused that cells may be Markdown, as shown up top, vs. Code. Like a spreadsheet, you can write lots of text between code sections. The markdown punctuation is a lot like what's used in Wikis, restructured text. Cheat sheet: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet (you can embed links, pictures, even Youtubes). Example: http://nbviewer.jupyter.org/github/4dsolutions/Python5/blob/master/Pi%20Day%20Fun.ipynb Also, it's not that the cells are "isolated" but define objects top to bottom, just like a Python module, so yes, if you come in cold and start running to last cells first, NameError problems are likely. Running them all, in order, is a one click option, as you mention. Nothing wrong with doing that. Speadsheets work the same way don't they? MathCAD does: you need all the names mentioned already defined higher up. Regarding your diff function, one *could* pass a function as an argument, no problemo, no need for fancy parsing etc. i.e. functions are just callable objects e.g.: def diff( func, x, h=1e-8): return ( func(x+h)-func(x) )/h then: def g(x): return x**2 - 2 >>> diff(g, 2) # passing the function as an argument, accept h default When you imported * from numpy, you got sin from there. You sounded surprised you could do that without importing it from math. More evidence of how the * may lead to confusion. The math version of sin and cos is what you *don't* want, as you're trying to feed in an np.arange, whereas the math version just accepts scalar numbers (degrees or radians) from numpy import arange, linspace would be another way to lose the np prefix, short of using a star. Tack on sin, cos. The sin, cos in math are *not* able to handle arange or linspace objects, so getting these from numpy is what you needed all along. Might not have needed math at all. But then explain how numpy is so vary oriented towards array processing. from numpy import arange, sin # this will work t = arange(0, 2, 0.1) sin(t) array([ 0. , 0.09983342, 0.19866933, 0.29552021, 0.38941834, 0.47942554, 0.56464247, 0.64421769, 0.71735609, 0.78332691, 0.84147098, 0.89120736, 0.93203909, 0.96355819, 0.98544973, 0.99749499, 0.9995736 , 0.99166481, 0.97384763, 0.94630009]) from math import sin # uh oh, this import of sin gets in the way sin(t) Traceback (most recent call last): Python Shell, prompt 8, line 1 builtins.TypeError: only length-1 arrays can be converted to Python scalars Note that in Python3, range(a, b) creates a "range type object", not a list, which is why you don't see the output as a list until the list comprehension. list(range(a,b)) will always get you the list representation. Thanks again! Kirby
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig