[Edu-sig] Another quick look at Codesters

2019-05-24 Thread kirby urner
I'm involved in a multi-state distance education program where I pop up as
a talking head, remotely. The kids have Chromebooks.  Middle School aged.
Here's a short Youtube about that platform:

https://youtu.be/HMOkOy9pCGo?t=69

(free to sign up, the tool our school uses -- the opening minute or so is
about another curriculum topic, hence the t=)

If you've not seen Codesters before, and have work in the Learning to Code
arena, you might wanna check it out.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Teaching Python Podcast

2019-05-07 Thread kirby urner
Thank you!  Very interesting.

I'm listening to:

https://www.teachingpython.fm/15

right now.

Good job tackling deeper philosophical issues around AI, not just talking
nuts and bolts.

Looking forward to more.

I teaching middle school Python too, once a week at the moment, as a
tele-teacher.  Pilot program.

Kirby


On Tue, May 7, 2019 at 1:47 PM Perry Grossman 
wrote:

> Hi All,
>
> You might find this Teaching Python Podcast of interest:
>
> https://www.teachingpython.fm/
>
>
> Perry
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Descriptor concept clarifies Python behind the scenes

2019-04-16 Thread kirby urner
Perfect to bring in the Descriptor protocol, right when we're talking about
'self' and also (per Trey's article), the different species of callable,
i.e. functions, methods (functions inside classes) and the classes
themselves (also callables, passing through to __init__, no need for
keyword 'new' as in Java or Javascript).

The code for a Property class in:

https://docs.python.org/3/howto/descriptor.html#properties

is about my deepest dive in an introductory course (and a longish one at
that).   We looked at it last week.  Tonight I look a little more at
Descriptors so all this edu-sig work counts as warming up.

This isn't "cheat sheet" level Python, that's for sure.

The actual property class (a built-in) isn't actually implemented in pure
Python.  The code in the docs is like "if it were" (written in Python) and
to prove they're not kidding, when I introduce one of those Circle types
(ala Raymond Hettinger) with co-varying attributes (change the radius, area
and circumference change; change the circumference, radius and area
change... etc.) wherein at the top I go:

from modelproperty import Property as property  # <-- overwrite builtin
property with doc simulation

class Circle:
def __init__(radius = 1):
self.radius = 1  # trigger setter (this won't store directly to
self.__dict__['radius'] thanks to @property)

@property
def radius(self):  # one could do the recomputations upon getting but...
return self._radius

@radius.setter
def radius(self, r):  # it makes the most sense to update other
dimensions when setting, no?
self._radius = r
self._area = pi * r * r
self._circumference = 2 * pi * r

and so on.

Everything works the same.  Even though we're using doc code instead.

With Property in view, one can see how circle.radius = 3 is triggering
circle.radius.__set__(3), because radius is now the name of a Property
instance (thanks to decorator syntax), and the radius.__set__ method
invokes a stored method fset

The first @property is swallowing the immediately following radius method
whole, and storing it in fget (a property attribute).

The invocation of @radius.setter then calls a Property method:

def setter(self, fset):
return type(self)(self.fget, fset, self.fdel, self.__doc__)

which cleverly returns a whole new Property instance, by keeping self.fget
as it was, while taking in fset as the new kid on the block.

The newer Property is now armed with what it needs, to make radius play
well with the others (area and circumference).

Kirby


On Tue, Apr 16, 2019 at 12:37 PM Wes Turner  wrote:

> When you access an attribute of a class object (a dict), the class
> attribute is looked up by __get__().
> the class's instance of that function attribute is 'bound'; it receives
> 'self' (an object reference) as its first argument.
>
> If you write your own __get__ (e.g. with functools.partial or
> functools.wrap),
> or try and assign a function to a class [instance],
> or create a @staticmethod or a @classmethod,
> you can more fully understand how methods receive self as their first
> argument.
>
> - https://docs.python.org/3/howto/descriptor.html#functions-and-methods
> - https://python-reference.readthedocs.io/en/latest/docs/dunderdsc/ :
>
> """
> Descriptor Protocol
> In general, a descriptor is an object attribute with “binding behavior”,
> one whose attribute access has been overridden by methods in the descriptor
> protocol: __get__(), __set__(), and __delete__(). If any of those methods
> are defined for an object, it is said to be a descriptor.
>
> The default behavior for attribute access is to get, set, or delete the
> attribute from an object’s dictionary. For instance, a.x has a lookup chain
> starting with a.__dict__[‘x’], then type(a).__dict__[‘x’], and continuing
> through the base classes of type(a) excluding metaclasses.
>
> However, if the looked-up value is an object defining one of the
> descriptor methods, then Python may override the default behavior and
> invoke the descriptor method instead. Where this occurs in the precedence
> chain depends on which descriptor methods were defined and how they were
> called. Note that descriptors are only invoked for new style objects or
> classes (ones that subclass object() or type()).
>
> The starting point for descriptor invocation is a binding, a.x. How the
> arguments are assembled depends on a:
>
> Direct Call
> The simplest and least common call is when user code directly invokes a
> descriptor method: x.__get__(a).
>
> Instance Binding
> If binding to a new-style object instance, a.x is transformed into the
> call: type(a).__dict__[‘x’].__get__(a, type(a)).
>
> Class Binding
> If binding to a new-style class, A.x is transformed into the call:
> A.__dict__[‘x’].__get__(None, A).
>
> Super Binding
> If a is an instance of super, then the binding super(B, obj).m() searches
> obj.__class__.__mro__ for the base class A immediately preceding B and then
> invokes the 

[Edu-sig] what is 'self'? (plus link to Trey's article on callability)

2019-04-16 Thread kirby urner
If we're ever at a loss for what to talk about, in this context, of Python
teachers, I could recommend a list of default topics, one of which would
always be...

What is this 'self'?

The self appears right when we introduce the class construct (keyword
class).  And then we say things like "Python provides it" or "Python fills
it in".  What is "it" then?  "It" is "the instance".  For some, things are
starting to get muddy.

For coders familiar with OOP style grammars i.e. they're coming from
another language such as JavaScript or Java (quite different I realize),
they've got a sense of it, from keyword 'this'.

However Python is widely touted as a gateway language into OOP style
thinking, so we get a lot of first timers.  We owe them a clear picture of
self.

One andragogical technique comes straight from the docs:

instance = C()
C.method(instance)   # <-- needs instance as argument

is equivalent to:

instance = C()
instance.method()  # <-- instance is "subject" as in subject.verb()

... of course we may add additional arguments at will, but lets keep it
simple.

In OOP, all the selves share the same template or class code, so how is
Python to distinguish one self from another?

It's not like each self is carrying around a copy of the method code. The
model is more like having DNA in common (a shared genetic core).

As in:

class Creature:

def eat(self, food):  # <--- needs to know which self
self.stomach.append(food)

With:

instance.eat("spaghetti")  # <-- self known to Python

we have enough info to figure out which self, and Python obligingly brings
it forward, to fill the placeholder, usually 'self'.

With:

Creature.eat(instance, "spaghetti")  # self supplied by the caller

we're not giving enough distinguishing information with generic Creature,
and so instance has to be provided, as the self.

Further andragogical elaboration involves showing what I mean by "usually
'self'" i.e. self is not a keyword but a placeholder.

Here I tend to go for a Chinese character substitute, e.g. for "Ego", to
remind the learner of Unicode in addition.  Emoji can't be Python names or
I might go for one of them.

***

Another good article by Trey Hunner just came out.  He's one of the more
prolific Python teachers *that I know about* (an important caveat as I'm
always missing *a lot*):

https://treyhunner.com/2019/04/is-it-a-class-or-a-function-its-a-callable/

He takes up the issue of "callables that are functions" versus "callables
that are actually types (classes)".

That can help with fine tuning one's sense of what a "type" is, plus
callability in general is a bridge to decorators, and this article
definitely goes there.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] What is an "object"?: Polyhedrons & OOP

2019-04-10 Thread kirby urner
Of course the literature contains numerous definitions.

A similar question might be "what is a noun?".

Objects are "that which the nouns name" in the Pythonic paradigm.  They
(the objects) live in memory at id() addresses ("like street addresses" I
might tell my students).

However, impressionable minds need more to hang a hat on that just boring
grammar words (like "noun").  In UML (universal markup language) we have
our customary symbols and diagrams:

https://atomicobject.com/resources/oo-programming/abstraction-and-identity

I often use a Creature -> Animal -> Mammal -> subclasses of Mammal
taxonomy, when introducing inheritance and what we call the MRO (method
resolution order).

Another association of "object" we might build upon is "polyhedron" or
"that which has shape".


class Polyhedron:

def __init__(self, v, f):
self.v = v
self.f = f
self.e = v + f - 2 # euler's law for polyhedra

def scale(self, factor):
"""
scale volume by factor, beget a new poly
"""
return type(self)(vol = self.volume * factor)

__mul__ = __rmul__ = scale

class Tetrahedron(Polyhedron):

def __init__(self, vol=1):
super().__init__(v=4, f=4)
self.volume = vol

class A(Tetrahedron):
def __init__(self):
super().__init__(vol=1/24)

class B(Tetrahedron):
def __init__(self):
super().__init__(vol=1/24)

# etc. (S, E, T)

class Cube(Polyhedron):
def __init__(self, vol=3):
super().__init__(v=8, f=6)
self.volume = vol

class Octahedron(Polyhedron):
def __init__(self, vol=4):
super().__init__(v=6, f=8)
self.volume = vol


etc. (longer list of subclasses).

If the Learning to Code curricula were to feature more source of this
nature, we could facilitate reaching out to the geometry teachers with an
intuitive picture of "dot notation" as a means of accessing "containers" of
a very literal kind, if abstract.

Associations around "object" have something concrete to build on, adding
generic methods such as rotate() -- about what axis? -- and translate() --
for moving the shape relative to others, or to an origin (could involve
creating a new shape at the new place, relative to the old).

We could easily add surface area as another attribute, along with default
edge length corresponding to our default volumes (YMMV in terms of what
defaults your curriculum chooses).

Indeed this is the right place to emphasize the power law, that changing
all edges by a factor of n, e.g. doubling them (n=2) changes area by n**2
and volume by n**3.

A selling point of the simple code base shown above is I'm not trying to do
anything vectorial yet i.e. the shapes are so far coordinate free.

We're free to turn to actual physical models and other media besides source
code, to flesh out the concepts we're talking about.  OO wins.  Geometry
wins.  Dot notation wins.  Python wins.

I've been taking this tack in my Youtubes lately, building up a stash for a
science fiction time when these ideas are more mainstream.

Not that this focus on Polyhedrons as paradigm objects is all that
esoteric.  Square and Circle types have been common in textbooks at least.
There's a bias against "3D" and I suppose that's what I'm countering, as
speaking experientially, we do not live in Flatland.

The approach to coding I'm advocating is also encouragement for spatial,
not just planar, visualizations.  Euclidean proofs may be more involved,
however we have other generalizations such as Euler's Law for Polyhedra and
Decartes' Deficit to introduce.

Having the OO experience tie in with spatial geometry more intimately
provides greater opportunities for imaginative play, and exercises the
computing machinery in ways it's already very good at.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] more about Codesters (in browser Python learning environment)

2019-03-08 Thread kirby urner
On Thu, Feb 28, 2019 at 9:37 PM kirby urner  wrote:

>
> BTW, I was a talking head in Houston, Texas yesterday early morning, two
> time zones distant, talking to high schoolers in a library about Python in
> the Workforce (their choice of title).
>
> There's a company called Nepris that serves as a go between, matching up
> people in industry with various classrooms.
>
> I certainly gave Jupyter Notebooks a lot of attention in that
> presentation.
>
>
If anyone wants to track this down (my talking head appearance in Houston),
here's a link:

http://controlroom.blogspot.com/2019/03/python-in-workforce.html

The Nepris machinery is behind the blog and takes awhile to furnish the
video in thumbnail.  Eventually it works.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] more about Codesters (in browser Python learning environment)

2019-02-28 Thread kirby urner
notebooks.ai looks very professional Santiago!  You're making Jupyter
Notebooks really easy to share.  You must be on the Jupyter Notebooks in
Education list?

jupyter-educat...@googlegroups.com

We have some overlap with edu-sig in terms of subscribers.

BTW, I was a talking head in Houston, Texas yesterday early morning, two
time zones distant, talking to high schoolers in a library about Python in
the Workforce (their choice of title).

There's a company called Nepris that serves as a go between, matching up
people in industry with various classrooms.

I certainly gave Jupyter Notebooks a lot of attention in that
presentation.

I didn't learn this was Texas (I was thinking Illinois) until the end.  Had
I known, I might have mentioned Enthought, an important company in
I-Python's evolution.

This was on zoom.us, which lets me jump from window to window showing 'em
stuff.  The talking head is in the corner.  I can see them too.

Speaking of Codesters and Anaconda stack both, I went on to make a second
Youtube today.

This one goes back and forth between Codesters and Spyder, hinting at ways
we might take a middle / junior high school class to a next higher level.

https://youtu.be/6wMADmMx1lo(Python: Humanities + STEM)

FYI, I have similarly themed Youtubes back in 2017, e.g.

https://youtu.be/Iptjjxrvyhk  (Python after Codesters)

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] more about Codesters (in browser Python learning environment)

2019-02-28 Thread kirby urner
I've posted quite a few times to edu-sig about Codesters, an in-browser
JavaScript platform (based on Skulpt) that runs a reduced Python, but with
added features.  Cool learning environment!

I've just uploaded another teaching Youtube, with a very live-demo flavor
i.e. the goal changes slightly as new strategies get adopted.  However,
there's measurable progress, as measured by me, the talking head.

https://youtu.be/0GYLToWnhI4
Season Changer in Codesters ( < 8 mins)

My eventual project, which I'm hoping the whole class will engage in (not
each working solo, but as a team), puts you in an 8x8 "chessboard" where
the arrow keys take you from square to square, and each square is a
background image.

That's a simple framework.  You may then imagine simple games such as
Buried Treasure based on this simple infrastructure.  A matrix of
hexagon-pentagons on a sphere?  That would be for another classroom and
platform. :-D

Codesters does implement the Turtle with penup, pendown, the directional
commands, so is in many ways another doorway into Logo-style 2D graphics.
It has a physics engine, with bouncy walls and gravity.  Go crazy!  Fun
world!

Again, don't think of Codesters as striving to be a Python3.  It's more
Python2 flavored and is a stepping stone, an instructive environment.

Here in the education sphere, we get to deal with (and even design) such
things. :-D  Many of us here have been trailblazers, still are.  Yay us!

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] the string type (was: making types matter (notes for beginners))

2019-01-28 Thread kirby urner
Thanks Wes, especially for the URLs relating type theory to "HoTT" by way
category theory.

My friend and co-podcaster Alex, a math-physics-philo guy, has been pushing
me to bone up in that area [1].  Those links really helped.

I'm squeezing some of this in while reading the OSCON 2019 proposals, a big
job, but I always learn a lot by so doing. [2]

When it comes to Beginner Python and types, people have a strong grasp of
number types coming in, especially ints, but think they know more about the
string type than they really do, thanks to the whole coding/decoding
business.

i.e. strings are always "encrypted" (encoded) a specific way, even if only
as plain ASCII text.  K-16 doesn't do a lot to introduce Unicode, even
though it's fundamental.  I'd teach Unicode in language arts, along with
fonts and old fashioned printing and book binding.

What I find works well with kids and adults alike is a lot of emphasis on
Emoji, which are now a part of Unicode after all.  They're colorful and
ubiquitous in modern life.

There's something satisfying about being able to have

["", "", ""]

as a Python list.

We can also use non-keyboard characters in identifiers, though emoji won't
work (there's no making your emojis callable in other words).

*** testing 1-2-3... how did that list come through in the Mailman
archives? Displayed as Emoji, not as missing glyphs?  I see Wes already
used a yellow hand pointing down, so I'm confidant the glyphs should be
there ***

Contemporary IDEs and web browsers are up to showing emoji.

When you think about Unicode as a database with records (fields as
attributes) you realize that the string type alone is a huge door opener.
It's also about number bases and HTML entities.  Lots to know.

About half of my students are middle schoolers [3], the other half are
adults [4].

The Emoji (Unicode) stuff works at all levels.

I notice the Rust docs are into it.

Show your language is Unicode savvy that way, good PR.

Kirby Urner
4dsolutions.net
cascadia.or.pdx

[1]
It's something of a joke how everyone starts a Monad tutorial the same way,
by decrying the dearth of coherent Monad tutorials, hah hah.

The emphasis on composing functions in category theory takes me to this
decorator class, my Monad in progress:

https://repl.it/@kurner/MakingMonads

https://youtu.be/caSOTjr1z18  (functional programmer speaking to his
community)
https://youtu.be/SknxggwRPzU  (Dutch prof with several relevant interviews
on computerphile channel)
https://youtu.be/IOiZatlZtGU  (good overview of how logic and CS come
together over time, focus on lambda stuff).

FYI, I've used "λ-calculus" (Church, Turing et al) to loosely brand an
alternative track through high school, that could in theory count with
future employers and colleges as much as today's prevelant "Δ-calculus"
(Newton-Leibniz).

Here's how I use λ-calc in contrast with Δ-calc (against a STEM backdrop --
I've since done more to map out PATH).
https://youtu.be/eTDH7m4vEiM

I'm simply sharing a vision (heuristic, gestalt), akin to science fiction,
not proposing legislation nor composing any "thou shalt" edict -- so no
need to get too political about it I'm hoping.  Food for thought.

[2] a Medium story (be me) that gives a big picture broad brush stroke
history leading up to the resurrection of O'Caml, the language:
https://medium.com/@kirbyurner/stories-from-cyberia-fc857867e147

[3]  middle school: next Coding with Kids gig starts tomorrow:
https://youtu.be/6qlj_AZqpto (a look at Codesters)

[4]  adults: next SAISOFT gig starts in February:
https://github.com/4dsolutions/SAISOFT
(lots of Jupyter Notebooks; we also use Spyder and vs code, both with
Anaconda)
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] making types matter (notes for beginners)

2019-01-25 Thread kirby urner
In my on ramp to Python, for beginners, I find harping on "types" a great
intro (if unoriginal -- a lot of us do it).

For one thing, we can hold fixed to the "type" idea while changing the
source of the type from built-in, to standard library module, to 3rd party
-- three tiers in my "dimensions of Python".

These dimensions are (again):

* keywords and core syntax (punctuation symbols e.g. [ ] ( ) : etc.)
* built-ins
* __ribs__ (special names e.g. __getitem__)
* standard library
* 3rd party (or cloud, or ecosystem, most of what you write yourself)

What I say about OO and types is:

this was an attempt to mirror your natural language thinking in terms of
things having type and thereby characteristics.  Computer languages were
reaching out to meet us half way, in our native context.  "Easy to reason
about" in proportion to one's having a strong sense of metaphor perhaps.
Not self-proving.

The datetime type is, like the string, great for escaping the vortex of
"number types only" (where high school math teachers seem to wish to
confine themselves for some reason, although this is not a limitation of
maths).

Many newcomers to programming expect incessant number crunching and
languages that only care about numeric methods. That's a stereotype to
smash early.  Some types help us do that.  I have a "permutation" type
that's like a number in being very mathy, supports __mul__ and __invert__,
but it's not a "number" type.

https://repl.it/@kurner/Permutations  (repl.it worth checking out if you
haven't)

datetime also persuades us to appreciate that others have dealt with the
complexity.  We get the fruits of their efforts.  Calendar stuff is sooo...
tedious?  Not forgetting timezones and daylight savings time.  It's a lot
of useful machinery that used to stay locked away in temples.

A good example of a 3rd party type?  Actually there's a lot of 3rd party
datetime stuff.

Lets get back to number crunching why not?  gmpy2 - Extended Precision
Decimals.  Very like decimals in Standard Library, which is great, for
comparing and contrasting similar types.

A strong focus on types right from the get go then helps explain the power
of Python's  'class' keyword:  Python lets you extend the type system with
types of your own.

That's the OO model after all (not at all unique to Python), and meant to
mirror reality in some ways, a different goal then being "easy to reason
about" (which is a holy grail as well  -- it's not either/or).

Example using of gmpy2 in a "learning Python" curriculum context:

https://nbviewer.jupyter.org/github/4dsolutions/Python5/blob/master/S_Train.ipynb
(more links from the bottom if wanting more of the same)

The feature I want to emphasize is the results of decimal calculations
mostly look like this:

JB Icosa:   18.512295868219161196009899292654531923571426913640152615969
JB Cubocta: 20.0
SuperRT:21.213203435596425732025330863145471178545078130654221097650

Not what you'd be seeing with a calculator (too precise).  Not floating
point numbers, clearly, in the sense of IEEE 754.

I find extended precision types useful for inspiring students to developing
that special and useful skill, of going from conventional sigma notation,
to working programs using loops -- what sigmas stand for.

Ramanujan had some doozies converging to Pi (or 1/Pi) or whatever.  We've
looked at those before on edu-sig.

Example:
https://github.com/4dsolutions/Python5/blob/master/Extended%20Precision.ipynb

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Question about certifying teachers

2019-01-24 Thread kirby urner
Hi Charles (fond memories from Google App Engine days... we met at a Pycon
in Chicago years ago)...

Issuing some proof of completion, in certificate form (an actual document
with their name on it, could be PDF) helps your enrollees put something on
their resume.  The other half of that equation is not a big name school or
company, though that might help, so much as a detailed course outline
and/or the actual course content, or both -- such that those following up
on this credential get a sense of what it means.

What did these students actually work through?  Were there projects?
Quizzes.  Describing the program helps too (including with recruiting new
enrollees).

When O'Reilly School of Technology closed its doors, I was clear that the
best way to support our alumni was to preserve a record of what we offered,
so those advertising completing our courses could point to something
objective, in terms of content covered.  OST listened and our content is
still online to this day.

Example pages:

http://archive.oreilly.com/oreillyschool/courses/programs.html
http://archive.oreilly.com/oreillyschool/courses/courses.html
http://archive.oreilly.com/oreillyschool/courses/Python1/index.html

We show our quizzes, but not our projects, not sure why at this point.

Students had to finish all the projects, which were assessed by their human
instructors.  We had no robo-grading whatsoever, not even for quizzes, as
we wanted them to know they had a real human on the other end.

Of course a lot of the code camp type websites don't provide actual
instructors to sign off on work, as you know.  They may have students
aseess each other (or not), ala Coursera, which, in combination with
deadlines, means not everyone who starts, manages to finish.

Attrition stats may or may not be relevant in your case.  If they got a
credential for just showing up (attendance), that's of course not as
impressive, so you do your students a favor by advertising the rigors of
your offerings.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] threads on teaching w/ jupyter (high school + France, Binder...)

2019-01-12 Thread kirby urner
Contributors here might want to add to this discussion thread or bookmark
it for the links:

https://groups.google.com/d/topic/jupyter-education/2Cv7B3td9LA/discussion

Overlaps our threads here quite a lot.

Also, I've been getting into using Binder more, with my Jupyter Notebooks
on Github.

Here's another thread on that:

https://groups.google.com/d/topic/jupyter-education/z9L4mTDyKsM/discussion

OSCON 2019 submissions still open a few more days...  hope to see some of
you there.

Good to see more PR for Math Adventures in Python out there.

https://nostarch.com/mathadventures

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] meeting the author of Math Adventures in Python

2018-12-29 Thread kirby urner
Twas my privilege to meet again with Peter Farrell (California)
this morning, and his twin bro from Bean Town (Boston).  They're
heading out tomorrow, as is my visiting family, as we close out
2018.

Peter wrote Hacking Math Class with Python and No Starch Press
is about ready to release Math Adventures in Python.  I've been
reviewing a PDF version.

What I'm facing myself is whether I think "writing games" is a best
doorway into coding.  For some, it clearly is.

However I always feel I'm shirking my real duties as a generalist
when I make it the point of MIT Scratch, or Codesters (Python
compiling to JavaScript) to make games and not math.

It's not either/or of course, and math leads to art pretty quickly.
That's a STEM to PATH bridge in my lexicon (more on Medium).

The hybrid of math and coding we're seeing in Farrell's books,
among others, seems more predictive of what's happening in
the core curriculum versus in these after school elective programs
I've been providing.

Peter has a better situation:  the students come to him, and
he's free to work in and test his math teaching ideas. That's
what I'd like too.  I'll talk to my bosses.

Peter and I first met at Pycon Portland 2017.  Speaking of which,
OSCON 2019 is still accepting talk proposals, I'm supposed to be
spreading the word (which I am).

Peter and I both look up to Daniel Shiffman of Coding Train, who
has been incorporating more Python in his Youtubes of late.
https://thecodingtrain.com/  His stuff gets very mathy sometimes.

Kirby

Follow-up:

http://mybizmo.blogspot.com/2018/12/another-math-summit.html
(related blog post the shows book cover)
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] re Python in France etc. (Python and...?)

2018-11-20 Thread kirby urner
I'm wondering if, when a curriculum embraces Python, this implies using
Jupyter Notebooks?

These two technologies seem so seamlessly connected in this day and age.

I'm not suggesting Notebooks replace an IDE.

But the idea of "coding" is changing given all the high level APIs out
there.  A pro in some field (other than software development) is likely to
run only a few lines of code at a time.  Google's TensorFlow tutorials take
this approach.

To say one is "learning Python" does not imply one is planning to write
applications, not even websites.  Python is a swap-in for MATLAB or R in
many contexts.  It's embedded.

Here's me on the Teaching with Jupyter Notebooks discussion list (public
archive) promoting the concept of embedding videos *about the very notebook
they're embedded within*.  Think of tutorials.  I link to an example,
viewed with nbviewer given Github skips showing the Youtubes in its native
rendering engine.

https://groups.google.com/d/msg/jupyter-education/3u1cvg1vza0/TYM1je1EAwAJ

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] "chopsticks" piano notes as ML feed in Intro Course (experimental)

2018-11-11 Thread kirby urner
Here's another case where I might have stumbled on an andragogic technique
another Python teacher is already well-known for using.  Or not, we shall
see.

Old technique (for teaching properties):

In an earlier chapter, I stumbled upon having @property decorate a circle
so you could change radius, area or circumference with simple "setattr" dot
notation e.g. c.area = 10, and the other two attributes would change
automatically. [1]

Thanks to how type property uses the Descriptor pattern, that's quite
doable and is a clear demonstration of what properties allow, drawn from
familiar grade school geometry.

Turns out:  Raymond Hettinger was sharing that little dharma already.  Same
karma!  Great minds think alike (if I do say so myself).

Aside:

I've been meaning to do more with triangles and tetrahedrons, using
@property... e.g. make AB longer and watch angles change.  Sticking to
right and/or equi-angular triangles keeps everything simpler. [2]

The new technique (for introducing data structures and machine learning):

So the new thing I might not be first to think of:

lets use the "chopsticks pattern" from the musical score of Chopsticks
(used universally in tutorials, almost a "hello, world" of Piano World) and
call the chopstick note pairs "correct" amidst a myriad "not correct" bytes.

Here's an octave:
C D E F G A B C

Chopsticks begins with

F and G pressed.
Then E and G.
Then D and B.
Then C and C.

The first 22 seconds of this Youtube give the idea:
https://youtu.be/waraNMP0kK8

So in "byte format":

0 0 0 1 1 0 0 0
0 0 1 0 1 0 0 0
0 1 0 0 0 0 1 0
1 0 0 0 0 0 0 1

are the "chopsticks" of interest.

Then have Machine Learning algorithms tease out the pattern.

Feed through 10,000 random strings of 1 and 0. [3]

Mark the chopstick patterns "correct" (1) and the not-chopstick patterns
"incorrect" (0), effectively forming a ninth column (the proverbial y in
machine learning, where all the samples are X).

This way, we get to play with (introduce) numpy.ndarrays and scikit-learn,
but with more familiar thoughts about piano keys in the foreground, and a
melody to boot.

How good are these learning machines, once trained?

Do they get random 10010100 right i.e. "not a chopstick"?  Are they right
every time?

If intrigued and want more code, here's the link to the Jupyter Notebook in
question:

https://github.com/4dsolutions/SAISOFT/blob/master/OrderingData.ipynb

(scroll to very end and come backwards would be my suggestion -- get the ML
part first).

I like how something so early in piano training feeds an intro to ML, given
how piano and "player piano" relate to AI, of which ML is a part.  Punch
cards and all that.

Very Westworld eh?

https://youtu.be/elkHuRROPfk
(not just Chopsticks anymore)

I'm looking for "pathways through Python" that consist of a combination of
"zoomed in" and "zoomed out" topics.  Sometimes we look at nitty gritty,
other times we need overview.

Kirby

[1]  this older version (Oct 2016) doesn't have perimeter (circumference).
Easy to add? (we do that as an exercise in class).

https://github.com/4dsolutions/Python5/blob/master/Descriptors%20and%20Properties.ipynb

[2]  I've got this dynamite volume method, not invented by me, that just
takes the six edge lengths for the arguments.

https://github.com/4dsolutions/Python5/blob/master/tetravolume.py  (used a
lot in my stash)

Lots more in the historical literature.  E.g.:

https://www.mathpages.com/home/kmath424/kmath424.htm

More context:

https://medium.com/@kirbyurner/uncommon-core-87a31b7f75b3

[3]

My current function for doing that is maybe too long-winded as I
concatenate strings.  Why not just convert to binary from random 0-255.  We
could do that.
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] learning Unicode through Jupyter (with Python)

2018-10-29 Thread kirby urner
Since full unicode is the current range of the default string type (str), I
find my initial explorations of strings often swerve into chess pieces,
playing cards, emoji.

Speaking of playing cards: I'm surprised to discover an unfamiliar face
card this late in life.  Unicode has a "Knight" (letter C) in all four
suits.  I'm so used to Bicycle decks with suits of 13.  I chop out all the
Knights using slice notation in the Notebook linked below.

The playing card motif is especially apropos around Python given the logo
has that face card symmetry, if you know what I mean.  I believe Luciano
Ramahlo does playing cards quite a bit, along with little flag GIFs (served
by nginx), which I think these days could be emoji.

If not bothering with Unicode, then why not just:

from random import shuffle

suits = "Hearts Clubs Spades Diamonds".split() # chop me up
royals = "Ace Jack Queen King".split() # could Ace be a she?  Sure!
normals = [str(i) for i in range(2, 11)] # starts at 1, stops at 10

deck = [ ]  # I'm an empty list

for s in suits:  # outer loop
for n in [royals[0]] + normals + royals[1:]: # Ace, normals, rest
card = (n, s)   # (suit, face value)
deck.append(card)

deck += ["Joker", "Joker"]  # need these too!
print("Fresh from box:\n", deck)
shuffle(deck)
print("Shuffled:\n", deck)

But then we'd probably want instances of the Deck class no?  Self
shuffling.

Besides, I think bothering with Unicode is worth the effort.

Lets not lazily pretend we still live in the days of ASCII.

Copying over from a publicly shared Jupyter listserv, one of mine from
yesterday:

===

"Orthogonal" to the programming languages (yet pops up in most of them):
 Unicode.

http://nbviewer.jupyter.org/github/4dsolutions/SAISOFT/blob/master/Unicode_Fun.ipynb

I'm finding Jupyter fun for exploring Unicode, in part because of HTML( )
enlargement possibility.

I approach it through Python, but other kernels could do that too.

I second Lee's enthusiasm for the Jake Vanderplas tutorials.

He gave a great keynote at a Pycon I went to here in Portland.
Kirby


On Sun, Oct 28, 2018 at 8:19 PM Lee Smith  wrote:

>
>
> On Wednesday, October 17, 2018 at 7:30:53 AM UTC-7, akash deep srivastava
> wrote:
>>
>> hi i am akash i'am student of today i'am staring a jupyter . i dont know
>> what is jupyter and what is the use so please help me and guide to jupyter .
>>
>
> Jupyter is a Browser that easily allows programming experiments.  First in
> Python, now there are C++ kernels being adopted.   You will find Juyper
> very useful since on line a number of people are publishing free courses
> written in a notebook.  Consider https://github.com/jakevdp.One of
> his 'Repitories'  -- folders is a complete elementary course in Python.  "
> WhirlwindTourOfPython "
>
>
>
 ===
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Jupyter Notebooks in the news again, thanks to Paul Romer Nobel Prize

2018-10-10 Thread kirby urner
Some links:

https://developers.slashdot.org/story/18/10/09/0042240/economics-nobel-laureate-paul-romer-is-a-python-programming-convert

https://qz.com/1417145/economics-nobel-laureate-paul-romer-is-a-python-programming-convert/

Shades of Atlantic Monthly, April issue (mentioned in 2nd link):

https://www.theatlantic.com/science/archive/2018/04/the-scientific-paper-is-obsolete/556676/

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] adventures in using Python as a calculator

2018-10-07 Thread kirby urner
A stereotype some people have, of computers, is they're like giant
calculators on steroids.

Then they find as much "text processing" goes on as "number crunching" -- ala
"regular expressions" -- and forget about the calculator model.
Calculators don't do strings, let alone much in the way of data files.  Of
course that line got blurred in the golden age of programmable calculators
(HP65 etc.).

However, the Python docs start with Using Python as a Calculator in Guido's
tutorial.

Perhaps we could do more to fulfill the "on steroids" expectations (that
the computer is a "beefed up" calculator device) by exploring our number
types in more depth, and in particular by exploiting their superhuman
abilities in the extended precision department.

Yes, the int type is awesome, now that it integrates long int (for those
new to Python, these used to be separate), but lets not forget Decimal and
also... gmpy, or actually gmpy2.

I've probably lost even some seasoned Python teachers in jumping to that
relatively obscure third party tool, providing extended precision numeracy
beyond what Decimal (in Standard Library) will do.  gmpy has a long
history, predating Python.  I'm not the expert in the room.

In particular, it does trig.

Our Python User Group used to get one of the package maintainers from
nearby Mentor Graphics (Wilsonville). He was adding complex numbers to the
gmpy mix, and was in touch with Alex Martelli.  I enjoyed our little chats.

Without having all the higher level math it might take to actually prove
some identity, and while starting to learn of those identities nonetheless,
extended precision would seem especially relevant.

"Seriously, I can generate Pi with that summation series?" Lets check.

Just writing the program is a great workout.

Some subscribers may recall a contest here on edu-sig, for Pi Day (3/14),
to generate same to a 1001 places, given one of Ramanujan's convergence
expressions for the algorithm.

https://github.com/4dsolutions/Python5/blob/master/Pi%20Day%20Fun.ipynb
http://mathforum.org/kb/thread.jspa?threadID=2246748

I had an adventure in gmpy2 just recently when my friend David Koski shared
the following:

from math import atan as arctan
Ø = (1 + rt2(5))/2
arctan( Ø ** 1) -  arctan( Ø ** -1) == arctan(1/2)
arctan( Ø **-1) -  arctan( Ø ** -3) == arctan(1/3)
arctan( Ø **-3) -  arctan( Ø ** -5) == arctan(1/7)
arctan( Ø **-5) -  arctan( Ø ** -7) == arctan(1/18)
arctan( Ø **-7) -  arctan( Ø ** -9) == arctan(1/47)
arctan( Ø **-9) -  arctan( Ø **-11) == arctan(1/123)
...

Without offering any kind of algebraic proof, I just wanted to see if the
arithmetic panned out.

These denominators on the right turned out to be a "bisection of the Lucas
numbers" (like Fibonaccis with a different seed).  That's a great job for a
Python generator, and only integers are involved.

But am I really confined to verification (not proof) using floating
points?  Not at all.  At first it seemed that way thought, because whereas
Decimal supports powering and roots, it's not equipped with atan.

Then I remembered gmpy2 and could all of a sudden push the number of
verifying decimals out past 92.  Definitely a calculator couldn't do this.

https://github.com/4dsolutions/Python5/blob/master/VerifyArctan.ipynb

Math students the world over, if free of the tyranny of calculators -- or
at least allowed to aid and abet (supplement) with Raspberry Pi etc. -- get
to dabble in these industrial strength algorithms, a part of their
inheritance.

Indeed lets use Python as a calculator sometimes, in accordance with said
Python.org tutorial.

A much stronger calculator, with a bigger screen, more keys, and a lot more
horsepower.

Kirby
PS:  I ran into this problem with gmpy2.atan: the above convergence wasn't
verifying beyond like 19 digits.  When I switched to gmpy2.atan2 istead,
everything started to work out.  The question being, why should atan(x) vs
atan2(y,x) differ except in terms of API?  gmpy2.atan2(y,x) computes the
arctan of y/x but in some other way apparently.  Food for thought.  I did
do some digging in the docs.
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Two Jupyter Notebook exhibits

2018-09-27 Thread kirby urner
I'm on a listserv where colleges and universities compare notes for using
nbgrader, while serving Jupyter Notebooks locally, as part of the
curriculum delivery architecture.

My way of sharing is less cloud-based in that I invite students to run the
course notebooks locally, each booting to localhost: using the JN
server that comes with Anaconda.  Or install with pip. They're getting me
live, closed circuit, and we're able to discuss the materials in real time
with no central server, other than shared Github repos and a course Google
Drive.  The difference is I'm not grading.  There's no requirement to turn
stuff in, just optional workouts during the tutorials.  More like at a
Pycon or OSCON.

Steve Holden was showing me JNs long before now, and I'm still far from
expert.

I appreciate them for many reasons, not the least of which is supporting
LaTeX.  The technology is also a meeting ground for folks from many walks
of life, given how the back end kernel need no longer be only Python.

I'm able to compare Python directly with JavaScript, in the same notebook
(such comparisons are worth making [1]).

===

Two exhibits:

This first one is from just this morning.  A Facebook friend has found a
numeric pattern, and what I see is an excuse to:

1) practice some LaTeX
2) show off Python generators
3) show off unittest
4) share about "evil" eval

The Decimal class does not support trig, so I'm not in a position to use it
as I did in the case of verifying the cited Ramanujan expression for 1/pi.

https://github.com/4dsolutions/Python5/blob/master/VerifyArctan.ipynb

The second:

Graphene & Quadrays is about using an obscure Vector class to create a hex
grid or hex mesh, written out by Python in Scene Description Language, and
changing to XYZ only at this last opportunity.  POV-Ray (free open source,
povray.org) doesn't understand about Quadrays.

However my algorithm for generating the mesh depends on the Python set type
and its ability to prevent duplicates, especially when the set members are
all 4-tuples of integers.  Floating point numbers get fuzzy and create
false negatives i.e. they're treated as different when they're not.  All
integer coordinates do not suffer from this deficiency.  Lots more about
Quadrays in my repo, or see Wikipedia.

[ I'm not saying XY coordinates cannot be overlaid on a grid of hexagons in
clever ways.  Many people have contributed nifty hex grid algorithms.  I'm
just showing another application for a coordinate system almost no one has
ever heard of.  I enjoy sharing esoterica.[2] ]

Quadrays assign integer coordinates not only to hexagonal mesh points, but
to the volume-filling equivalent FCC (=CCP) = rhombic dodecahedrons
space-filling matrix.  I take that up in a connected Notebook. [3]

https://github.com/4dsolutions/Python5/blob/master/GrapheneWithQrays.ipynb



ENDNOTES

[1]
https://medium.com/@kirbyurner/as-a-python-instructor-i-tend-to-recommend-a-polyglot-approach-learn-a-minimum-of-two-languages-243a0ed05eeb

[2]  https://www.redblobgames.com/grids/hexagons/
is an authoritative website on the topic.

[3]
https://github.com/4dsolutions/Python5/blob/master/Generating%20the%20FCC.ipynb
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] REQ: HOWTO mailing lists resources

2018-09-24 Thread kirby urner
I wanted to followup on this thread as since Aug 30 I've linked to it from
several places.

I've long had a habit of taking advantage what a publicly archived listserv
permits:  http linking from elsewhere.
There's a link to a Python repo in the end notes.

Otherwise I'm mostly just fleshing out a use case vis-a-vis mailman,
confirming insights by Wes.

On Thu, Aug 30, 2018 at 3:16 PM Wes Turner  wrote:

...

> TBH, securing and upgrading mailing lists is beyond the competencies of
> most volunteer-run organizations;
> which is one reason that I'd recommend Google Groups or similar for most
> organisations.
>
>
Indeed, my experiences matches.

The science fiction fantasy I was pursuing at the time, in my role, was
that my religious sect in particular (for which I was wearing an IT hat)
would eventually embrace IT expertise as one of its trademarks, a kind of
branding maneuver.  So sects are known for their chocolates and cheese.
We'd stand out for our IT expertise.

I was challenging my peers to "geek out" as we say.  Some rose to the
occasion.  I wasn't the only IT type on the listserv (one of Google's).

BTW I haven't given up on any of that investment in a higher tech look and
feel, even though my personal tour of duty in that specific role ended
quite a long time ago.  That gig, as a Clerk of IT for my region, was a
growth experience.

I also continue fantasize about future meeting facilities in a high rise
(as in "skyscraper"), for example some 47th floor facility in Singapore
would be no contradiction in terms, not a culture clash.  I picture a
serene scene, perhaps with LCDs in the social area, sometimes cycling
through pictures of those more iconic meetinghouses of the hallmark sort,
many of them wood-heated and by this time fairly dilapidated.[1]

> In my experience, ISPs offer GUI installers for various app on shared
> hosting platforms, but upgrades aren't managed in the same GUI; which
> requires a volunteer to keep the apps upgraded with at least security
> updates.
>
>
Exactly right.

I'm on Godaddy myself and find Wordpress nags me and upgrades in place
through its own GUI, but that's the exception, and is ironically the most
infested with stuff.

I had to SSH in and manually vim stuff out and vacuum tons of garbage
directories -- I've not been a great janitor over the years (this was
grunch.net). The website had essays and links I'd never put there, mostly
tucked away unobtrusively so as not to attract my attention.

Other upgrades, outside of Wordpress would require that I SSH in.  At NPYM,
we had no shell access that I recall, but my memory dims.

To this day we make intensive use of Drupal -- but the security patch
process was hardly intuitive (I wasn't handling it myself).

Our PHP was falling behind, version-wise.

In other words, we already had an inhouse-written and maintained PHP +
MySQL database.  Geeks R Us.

I was able to test run SQL from a command line, thanks to help from Marty,
and was suggesting we migrate these skills through the Secretary's office.
Those proposals remain on file.  I wrote a new prototype of our database in
Python.[2]

Kirby
[1]  https://youtu.be/PhsvqbCIaAs  (opening 5 seconds show iconic
meetinghouse, the rest being a music video recording of religious doctrines)

[2]  https://github.com/4dsolutions/NPYM
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] multiple inheritance and method resolution order

2018-09-07 Thread kirby urner
Addendum (copyleft, re-use and modify at will)
+ related links


[The]
>  "where's Waldo" exercise and this investigation into the MRO may be
> combined:  bury a waldo() instance or class method somewhere in the Genesis
> family
> [tree],
>

===

class Gen0 (object):
"""the Old One"""

def __init__(self):
print("__init__ of {}".format("Gen0"))

class Adam(Gen0):
"""one of two in Gen1"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Adam"))

class Eve(Gen0):
"""one of two in Gen1"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Eve"))

def waldo(self):
print("Waldo in {}".format("Eve"))

class Cain(Adam, Eve):
"""Gen2"""
def __init__(self):
super().__init__()
print("__init__ of {}".format("Cain"))


class Abel(Adam, Eve):
"""Gen2"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Abel"))


class Seth(Adam, Eve):
"""Gen2"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Seth"))

class Azura(Adam, Eve):
"""Gen2"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Azura"))

class Enosh(Seth, Azura):
"""Gen3"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Enosh"))

class Kenan(Enosh):
"""Gen4"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Kenan"))

class Mahalaleel(Kenan):
"""Gen5"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Mahalaleel"))

class Jared(Mahalaleel):
"""Gen6"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Jared"))

class Enoch(Jared):
"""Gen7"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Enoch"))

class Methusela(Enoch):
"""Gen8"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Methusela"))

def waldo(self):
print("Waldo in {}".format("Methusela"))

class Elisha(Enoch):
"""Gen8"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Elisha"))


class Lamech(Methusela):
"""Gen9"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Lamech"))

class Ashmua(Elisha):
"""Gen9"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Ashmua"))

def waldo(self):
print("Waldo in {}".format("Ashuma"))


class Noah(Lamech, Ashmua):
"""Gen10"""

def __init__(self):
super().__init__()
print("__init__ of {}".format("Noah"))


if __name__ == "__main__":
import inspect
subject = Noah()
subject.waldo()
print(inspect.getmro(subject.__class__))

===

Related posts:

https://grokbase.com/t/python/edu-sig/066kd86zh1/rich-data-structures-plus-knowledge-domain-object-sets
https://mail.python.org/pipermail/edu-sig/2012-December/010709.html
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] multiple inheritance and method resolution order

2018-09-07 Thread kirby urner
I have a standard exercise in sharing Python's data structures, wherein I
bury the string "Waldo" in some deeply nested object, say as an element in
a tuple in a dict in a list... to some demented level.[1]

When we're learning Python grammar, that's when "demented" makes sense i.e.
this isn't about writing production code so much as getting the basic
principles.

Along similar lines, when introducing super() and the method resolution
order, I'm often looking for a class hierarchy that (A) involves multiple
inheritance, (B) is several levels deep and (C) has "diamond patterns".

Finally it hit me:  I could turn to the Book of Genesis for a family tree
with all these features, plus the advantage of being easy to lookup.

Adam and Eve had several kids (they lived enormously long lives by today's
standards), and the siblings had to have kids by each other given they were
the only humans on the planet.  Adam and Eve's son Seth and daughter Azura
(two cases of multiple inheritance), had a son (another case).  Also,
Noah's mom goes back to a great grandparent shared with his dad.  Diamond
pattern.  Eureka.

There's already some precedent in mixing CS with bible studies (thinking of
Knuth), and besides, Python is heavily used in the humanities for natural
language processing.

Bridging from Python to Genesis doesn't seem too far-fetched. :-D

http://nbviewer.jupyter.org/github/4dsolutions/SAISOFT/blob/master/OO_Paradigm.ipynb
(see "Multiple Inheritance")

There "where's Waldo" exercise and this investigation into the MRO may be
combined:  bury a waldo() instance or class method somewhere in the Genesis
family try, in a couple places and go:

>>> subject = Noah()
>>> subject.waldo()

to find out where the name resolves.  Have the waldo method report on its
class.

Kirby

Cross reference to connected edu-sig topic:  Rich Data Structures

[1]  Example code:

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 17 17:23:45 2017

@author: Kirby Urner

Example of the "Where's Waldo" genre:
https://i.ytimg.com/vi/SiYrSYd7mlc/maxresdefault.jpg

Extract "Waldo" from each data structure

"""

data = {"id:":["Joe", "Smith"],
"mother": ["Judy", "Smith"],
"father": ["Waldo", "Smith"]}

waldo = "???" # output "Waldo"
print(waldo)
#
data = {"Waldo": {"scores":[34,56,23,98,89]}}

waldo = "???" # output "Waldo" hint: dict.keys()
print(waldo)
#
data = {(1,2):{"Name":["Waldeen", "Smith"]},
(4,5):{"Name":["Waldorf", "Smith"]},
(9,0):{"Name":["Waldo", "Smith"]}}

waldo = "???" # output "Waldo" hint: tuples may be keys
print(waldo)
#
data = ["Joe", 3, 7, ["dog", ("cat", "Waldo")], 27, {}]

waldo = "???"
print(waldo) # output "Waldo'

#
data = ([], [], ())
data[1].append("Wendy")
data[1].append("Waldo")
data[1].append("Willow")
# where's Waldo?
waldo = "???" # 
print(waldo)

# NOW MAKE UP SOME OF YOUR OWN!
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] training materials and learning environment for teaching kids python available

2018-09-05 Thread kirby urner
Many thank yous for sharing this.

I'm on board with having the language control things, ala Logo, actual
physical devices, as in Arduino or Lego, or virtual, as in Codesters and
your GUI / API.

André Roberge
, an edu-sig subscriber, has a strong track record on the "control robots"
front.


https://github.com/aroberge

The maintainer of Python's native turtle module is also an archive
contributor.

https://docs.python.org/3.3/library/turtle.html

We've been recently debating its coordinates feature, André having
identified an inconsistency.

https://mail.python.org/pipermail/edu-sig/2018-June/011908.html  etc.

Welcome aboard.

Kirby



On Sat, Sep 1, 2018 at 7:36 AM Kent Tong  wrote:

> Hi all,
>
> This is a set of training materials I used to successfully teach Python to
> kids as little as 10 years old. It was a success because the kids didn't
> just finish the course, they independently completed most of the coding
> challenges by applying the knowledge they had learned.
>
> The first four lessons and a lite version of the learning environment are
> freely available at:
> https://www.istudycenter.org/yes-kids-can-learn-python
>
> Let me know your ideas.
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] REQ: HOWTO mailing lists resources

2018-08-30 Thread kirby urner
> But where does it teach me TO mailing list?
> I think that's the real question here.
>
>
Just to clarify what you're asking, here's a use case:

I was a volunteer Clerk of IT for a religious group that conducts business
on-line but mostly by stowing information at a website, with all the
headaches of managing logins to control who gets to post where.  Drupal.

My recommendation was we imitate Python.org a lot more by setting up
mailman listservs with varying degrees of visibility to the public (some
are members only and so on).  I set up a Google Group by was of
demonstration and ran it for a couple years.  It's still out there.

The advantage of mail-lists are not only are they searchable but they
maintain the context and threads of conversation, great for organizational
memory. However, for historical reason, our clerks prefer to use conference
calls in real time, with someone taking minutes for the archives.  A lose a
lot that way.

There's lots more listserv use since my tenure ended, by various interest
groups, but no centralized place at the regional level for these listservs
to go, which is probably just fine (we're pretty informal), however I never
did find how I could get mailman servers installed at our ISP, back when I
was filing reports and proposals.

Our ISP only offered ancient majordomo as a listserv option, with precious
little information on how to set one up.

How does one set up a bunch of domain-name specific mail servers ala
Python's mm3, is that in the ballpark of what you're asking?

Kirby

>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Python teacher notes, preparing for class...

2018-08-30 Thread kirby urner
On Thu, Aug 30, 2018 at 3:02 AM Wes Turner  wrote:

> > By default, the sorted function looks at the leftmost element of a tuple
> or other iterable, when sorting...
>
>
You're right, my presentation is unclear.  I'll fix it.

The way it reads, it seems like you're implying that sorted() does this:
>
>
Yes, and that's wrong.

> >>> l = [(3, 2), (3, 1), (1, 1, 2), (1, 1)]
> >>> sorted(l, key=lambda x: x[0])
> [(1, 1, 2), (1, 1), (3, 2), (3, 1)]
>
>
> > You'll find some excellent overview of the magic methods in this essay
> by Rafe Kettler: A Guide to Python's Magic Methods. He's mostly looking at
> Python 2.7, so does not pick up on the __next__ method, however you'll be
> able to fill in the blanks thanks to this course
>
> This is unclear to me. What does the next() function do? How do I find the
> docs and source for it?
>
>
next(obj) triggers obj.__next__() which in 2.7 is named next internally
i.e. isn't magic.

__next__ is the main driver of iterators e.g. for loops hit __next__ over
and over as they loop over whatever.

True, a list (iterable) doesn't have a  __next__, but a for loop implicitly
applies __iter__ (called by the iter function) which turns iterables into
iterators.

> These are misspelled:
>
> > comparitor
> > compartor
>
>
Will fix next.



> These are great:
> - http://www.scipy-lectures.org/intro/language/python_language.html
> -
> http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-1-Introduction-to-Python-Programming.ipynb
>   - Something about sorted with a link to the docs would be a good
> addition.
>
>
Thanks.  Yes, I'll add some links to the docs as you suggest.  Great
feedback!

Actually as part of my class I'm showing them edu-sig and other python.org
lists, so we were actually viewing this conversation.  I'll extend that to
showing your corrections, as I want to demonstrate how the Python community
all teaches each other, is friendly and so on.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Python teacher notes, preparing for class...

2018-08-29 Thread kirby urner
> I tested that out in my OrderingPolys.ipynb (Jupyter Notebook).  Great!
> I'm keeping the demo.
>
>
> http://localhost:8889/notebooks/Documents/SAISOFT/SAISOFT/OrderingPolys.ipynb
>


https://github.com/4dsolutions/SAISOFT/blob/master/OrderingPolys.ipynb

Sorry, my bad.  I gave the local URL on my laptop vs the global one @
Github.

Kirby

>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Python teacher notes, preparing for class...

2018-08-29 Thread kirby urner
> This is the most unified reference on __dunder_methods__ ('magic methods')
> I've ever seen:
> "A Guide to Python's Magic Methods"
> https://rszalski.github.io/magicmethods/
>
>

I'd not seen that Guide to magic methods before.  Thanks!

>From perusing it, I was reminded of a topic Trey Hunner discussed in one of
his recorded live chats:

When defining how your class implements ordering, e.g. using __lt__,
__gt__, __eg__ and so on, it's sufficient to define just two of these, then
decorate with @total_ordering to have Python fill in the blanks.

I tested that out in my OrderingPolys.ipynb (Jupyter Notebook).  Great!
I'm keeping the demo.

http://localhost:8889/notebooks/Documents/SAISOFT/SAISOFT/OrderingPolys.ipynb

This Notebook now includes a link back to Rafe's docs.  I'll be sure my
California students know about this update.  We meet again tonight.

I use geometry, polyhedrons in particular, as an excuse to introduce OOP
from yet another angle (I take a multi-faceted approach).

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Python teacher notes, preparing for class...

2018-08-27 Thread kirby urner
My flight plan for sharing Python this evening, adult audience, real time
in cyberspace, includes going backstage to survey the Python for Developers
view.

That will mean optionally cloning the Github site that's mainly a Sphinx
HTML document about how to participate in Python's evolution.

https://github.com/python/devguide  (show how Sphinx works)

I don't plan on actually compiling Python tonight, but we'll be right where
one needs to be to learn how.  Just looking at the issues tracker (first
time) and PEPs (again) will inspire students with how well-oiled a machine
is the Python "sausage making" factory.

In my estimation, a well-rounded knowledge of Python includes understanding
how to make one's own decorators and context managers.

The following categories of type should also be made clear:

* Mutable vs Immutable
* Callable vs not
* Collections: Sequences vs Mappings
* Iterator vs Iterable
* Generator as Iterator
* Context Manager
* Descriptor

We recognize these types based on the assortment of "__ribs__" (special
names) they contain e.g. callables have __call__, mutables support
__setitem__, iterators have __next__, context managers __enter__ and
__exit__, Descriptors __fget__, __fset__ and so on.  We're like bird
watcher with binoculars, identifying species based on these tell-tale
characteristics (APIs).

A grand synthesis involves using the @contextmanager decorator from
contextlib to turn a generator into a context manager.  That's a high point
(summit) in my curriculum.

The Descriptor concept works in tandem with decorator syntax to bring us
the @property type.  I use a "magic circle" type for properties, meaning
you can set radius or circumference or area of a Circle, and the other two
attributes reset automatically.  I believe Raymond Hettinger uses the same
approach.

One of my most computer sciency types is the Permutation class, with many
soft links to Group Theory.  My P class randomly generates a dict with
[a-z] plus space (' ') mapped to the same set, keys to values in a
different order.  I have voluminous writings on how one might use this
class to explore elementary group theory on math-teach @ Math Forum, public
archives, no longer open to new comments.

https://repl.it/@kurner/Permutations
http://mathforum.org/kb/message.jspa?messageID=10227508
https://github.com/4dsolutions/Python5/blob/master/Permutations.ipynb

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What to teach: sorting algorithms vs OOP?

2018-08-17 Thread kirby urner
On Thu, Aug 16, 2018 at 11:24 AM, kirby urner  wrote:

>
> I'm glad Tobias took the bull by the horns and didn't eschew  a deeper
> look into the sorting algorithms.
>
> As a big fan of animations, my reflex is to scour Youtube for graphical
> renderings of the different strategies
>

e.g.:

https://youtu.be/ZZuD6iUe3Pc

Check out the BBC spin (heavy into sorting):

https://youtu.be/gOKVwRIyWdg

(I'd gladly show this in my school)
Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What to teach: sorting algorithms vs OOP?

2018-08-16 Thread kirby urner
I'm glad Tobias took the bull by the horns and didn't eschew  a deeper look
into the sorting algorithms.

As a big fan of animations, my reflex is to scour Youtube for graphical
renderings of the different strategies, but then another thought crops up:
lets get out of our seats and do choreography, Math is an Outdoor Sport!
(PR poster). I should explain.

The relationships between programming and scripting theater "programmes"
(old spelling) are deep. Give each student a postit with a number and have
them *enact* the sorting algorithm.  E.g. starting in a row, turn to person
on your left (if there is one) and swap places if your postit number is
higher...  have directors  and make a video.  Now choreograph (enact,
dance) in a different way.

Symphonies, plays, musicals, are so multi-track, so parallel, and yet we
fail to exploit those intuitions sometimes.

Let the Theater Department handle it, in consultation with CS.  Could go
under the heading of "Unplugged".  Likely the Hobbits are already doing
this in New Zealand (NZ has pioneered unplugged more than most, plus has
Hobbits).

Seriously, having lived in the Philippines where people routinely learn
group dancing, I'm worried about only acting as teams in three capacities
(a) cheerleader (b) athlete on the field (c) band.  Theater is being
eliminated in favor of competitive sports.  Perhaps CS could come to the
rescue and say "wait, we need Theater for our simulations".

More cerebral team-based activities might go a long way towards fighting
the stereotype that computer programmers  only live in artificially lit
basements eating pizza.  That's a physically damaging lifestyle, nothing to
do with writing code or even doing math.

===

Regarding last night's tele-class (real time, zoom.us), I worked through
"cloning a github repo" as the core exercise, a repeat from last week, then
went through the process of updating a notebook live, and pushing the
changes back to the repo.

The repo was of course the one with yesterday's Jupyter Notebook about
Ordering Polyhedrons by volume.

https://github.com/4dsolutions/SAISOFT

I tell them "cloning a github repo" is going to be important for when they
want like a Jake Vanderplas tutorial, i.e. when they want to study a topic
in more depth and the workshop is (A) on Youtube or similar service and (B)
the workshop materials are free via github (a common enough pattern).

I also reminded them how Google shares TensorFlow in the form of Colab
exercises (Jupyter Notebooks).

One students asked "R or Python, which is winning in Data Science"?

My answer:  pandas is a relatively recent development and there's already
lots of excellent curriculum based around R, which is likewise free / open
source. The business world is rushing into Python because of DL / ML and so
gains an R-like tool in the process, which enables better town-gown
relations i.e. Harvard can talk to Facebook about Pytorch thanks to already
teaching R in the stats department.

In other words, it's not either/or, more like two communities forming a
bridge via the common language of data science, which R and Python both
reflect (as do some other languages / ecosystems, not aiming for
comprehensivity here).

Kirby



On Wed, Aug 15, 2018 at 10:04 AM, Tobias Kohn  wrote:

> Hi Jurgis,
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What to teach: sorting algorithms vs OOP?

2018-08-15 Thread kirby urner
OUTPUT:

By volume: [Tetrahedron(v=1), Cube(v=3), Octahedron(v=4),
Cuboctahedron(v=20)]
By name:   [Cube(v=3), Cuboctahedron(v=20), Octahedron(v=4),
Tetrahedron(v=1)]


===

Here's a Jupyter Notebook version of my posting from this morning:

https://github.com/4dsolutions/SAISOFT/blob/master/OrderingPolys.ipynb

I'll test it out with my adult Python students this evening.  We've been
looking at sorting and lambda expressions.

Diving into Polyhedrons as a topic, without actually rendering them, would
be frustrating.

Fortunately, I've already got rendering backends implemented, going back
some decades.

http://www.4dsolutions.net/ocn/cp4e.html

When it comes to merging math with OOP, I think Polyhedrons look very
promising.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What to teach: sorting algorithms vs OOP?

2018-08-15 Thread kirby urner
OUTPUT:

By volume: [Tetrahedron(v=1), Cube(v=3), Octahedron(v=4),
Cuboctahedron(v=20)]
By name:   [Cube(v=3), Cuboctahedron(v=20), Octahedron(v=4),
Tetrahedron(v=1)]

[ weird tweet link appears here in the archive ]

Interesting that a URL to a tweet (not one of mine) snuck into the archived
copy of this message, even though I don't see it in the outgoing or
incoming emailed versions.

It shows the Portland skyline these days, when regional forest fires have
made the atmosphere really hazy.

https://mail.python.org/pipermail/edu-sig/2018-August/011990.html
(archived post)

Kirby
(wearing listowner hat)





On Wed, Aug 15, 2018 at 9:01 AM, kirby urner  wrote:

>
> Hi Jurgis --
>
> I've tried various approaches with K-12, noting that's in itself a wide
> spectrum i.e. K is nothing like 12.
>
> I'll focus on high school (9-12).
>
> I'd say the ubiquity (omnipresence) of the "dot operator" as "accessor"
> suggests working it into ordinary mathematical thinking, at first as a way
> to reach "attributes" (properties) and second as a way to trigger
> behaviors.  noun.attribute versus noun.behavior().  Why isn't "dot
> notation" part of everyday math?  Given the influx of CS in lower grades,
> I'd say it's becoming so, defacto.
>
> One mathematical object that calls out for such treatment is the
> Polyhedron, since that's obviously mathematical anyway, and is clearly an
> Object in the most literal sense.  Polyhedrons are colorful and accessible
> and help make that bridge to game engines providing visuals.
>
> >>> tet = Tetrahedron() # could come with many defaults
> >>> tet.edges
> 6
> >>> tet.vertexes
> 4
> >>> tet.faces
> 4
>
> What behaviors do we expect from a polyhedron?
>
> For starters:
>
> tet.rotate(degrees, axis)
> tet.scale()
> tet.translate(vector).
>
> We see how surface area increases as a 2nd power of change in linear
> scale, volume as a 3rd power e.g.:
>
> >>> tet.volume
> 1
> >>> bigtet = tet.scale(2)  # double all edge lengths
> >>> bigtet.volume
> 8
> >>> biggest = tet.scale(3)  # triple all edge lengths
> >>> biggest.volume
> 27
>
> Your earlier focus on sorting might still be used, as a typical behavior
> of mathematical objects, such as lists.
>
> Your focus is perhaps less on the algorithms used and more on the syntax
> e.g. .items() as a behavior of the dict type.
>
> That segment in Python where we show how to sort on any element of a tuple
> might be worth covering:
>
> >>> polyvols = {"tetrahedron":1, "octahedron":4, "cube":3,
> "cuboctahedron":20}
> >>> vols_tuples = tuple(polyvols.items())
> >>> vols_tuples
> (('tetrahedron', 1), ('octahedron', 4), ('cube', 3), ('cuboctahedron', 20))
>
> >>> sorted(vols_tuples)  # alphabetical
> [('cube', 3), ('cuboctahedron', 20), ('octahedron', 4), ('tetrahedron', 1)]
>
> >>> sorted(vols_tuples, key=lambda t: t[1]) # by volume, get to use  lambda
> [('tetrahedron', 1), ('cube', 3), ('octahedron', 4), ('cuboctahedron', 20)]
>
> another way, not using lambda, shown in the docs on sorting:
>
> >>> from operator import itemgetter
> >>> getvol = itemgetter(1)  # get item 1 of a tuple or other object using
> __getitem__
> >>> getvol(('tetrahedron', 1))
> 1
>
> >>> sorted(vols_tuples, key=getvol)
> [('tetrahedron', 1), ('cube', 3), ('octahedron', 4), ('cuboctahedron', 20)]
>
> https://docs.python.org/3.7/howto/sorting.html
>
> Like Wes said, you could bridge to inheritance here (if in Python,
> interfaces are less required as we have multiple inheritance).
>
> class Polyhedron  # base class
>
> could implement the generic guts of a polyhedron with subclasses like:
>
> class Tetrahedron(Polyhedron)
> class Cube(Polyhedron)
> class Octahedron(Polyhedron)
> class Cuboctahedron(Polyhedron)
> ...
>
> The special names __lt__ __eq__ __gt__ for <, ==, > will even let you
> implement sorting, in say volume order.
>
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
> Created on Wed Aug 15 08:31:57 2018
>
> @author: Kirby Urner
> """
>
> class Polyhedron:
>
> def __lt__(self, other):
> return self.volume < other.volume
>
> def __gt__(self, other):
> return self.volume > other.volume
>
> def __eq__(self, other):
> return self.volume == other.volume
>
> def scale(self, factor):
> return type(self)(v=self.volume * factor**3)
>
> def __repr__(self):
> retu

Re: [Edu-sig] What to teach: sorting algorithms vs OOP?

2018-08-15 Thread kirby urner
Hi Jurgis --

I've tried various approaches with K-12, noting that's in itself a wide
spectrum i.e. K is nothing like 12.

I'll focus on high school (9-12).

I'd say the ubiquity (omnipresence) of the "dot operator" as "accessor"
suggests working it into ordinary mathematical thinking, at first as a way
to reach "attributes" (properties) and second as a way to trigger
behaviors.  noun.attribute versus noun.behavior().  Why isn't "dot
notation" part of everyday math?  Given the influx of CS in lower grades,
I'd say it's becoming so, defacto.

One mathematical object that calls out for such treatment is the
Polyhedron, since that's obviously mathematical anyway, and is clearly an
Object in the most literal sense.  Polyhedrons are colorful and accessible
and help make that bridge to game engines providing visuals.

>>> tet = Tetrahedron() # could come with many defaults
>>> tet.edges
6
>>> tet.vertexes
4
>>> tet.faces
4

What behaviors do we expect from a polyhedron?

For starters:

tet.rotate(degrees, axis)
tet.scale()
tet.translate(vector).

We see how surface area increases as a 2nd power of change in linear scale,
volume as a 3rd power e.g.:

>>> tet.volume
1
>>> bigtet = tet.scale(2)  # double all edge lengths
>>> bigtet.volume
8
>>> biggest = tet.scale(3)  # triple all edge lengths
>>> biggest.volume
27

Your earlier focus on sorting might still be used, as a typical behavior of
mathematical objects, such as lists.

Your focus is perhaps less on the algorithms used and more on the syntax
e.g. .items() as a behavior of the dict type.

That segment in Python where we show how to sort on any element of a tuple
might be worth covering:

>>> polyvols = {"tetrahedron":1, "octahedron":4, "cube":3,
"cuboctahedron":20}
>>> vols_tuples = tuple(polyvols.items())
>>> vols_tuples
(('tetrahedron', 1), ('octahedron', 4), ('cube', 3), ('cuboctahedron', 20))

>>> sorted(vols_tuples)  # alphabetical
[('cube', 3), ('cuboctahedron', 20), ('octahedron', 4), ('tetrahedron', 1)]

>>> sorted(vols_tuples, key=lambda t: t[1]) # by volume, get to use  lambda
[('tetrahedron', 1), ('cube', 3), ('octahedron', 4), ('cuboctahedron', 20)]

another way, not using lambda, shown in the docs on sorting:

>>> from operator import itemgetter
>>> getvol = itemgetter(1)  # get item 1 of a tuple or other object using
__getitem__
>>> getvol(('tetrahedron', 1))
1

>>> sorted(vols_tuples, key=getvol)
[('tetrahedron', 1), ('cube', 3), ('octahedron', 4), ('cuboctahedron', 20)]

https://docs.python.org/3.7/howto/sorting.html

Like Wes said, you could bridge to inheritance here (if in Python,
interfaces are less required as we have multiple inheritance).

class Polyhedron  # base class

could implement the generic guts of a polyhedron with subclasses like:

class Tetrahedron(Polyhedron)
class Cube(Polyhedron)
class Octahedron(Polyhedron)
class Cuboctahedron(Polyhedron)
...

The special names __lt__ __eq__ __gt__ for <, ==, > will even let you
implement sorting, in say volume order.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 15 08:31:57 2018

@author: Kirby Urner
"""

class Polyhedron:

def __lt__(self, other):
return self.volume < other.volume

def __gt__(self, other):
return self.volume > other.volume

def __eq__(self, other):
return self.volume == other.volume

def scale(self, factor):
return type(self)(v=self.volume * factor**3)

def __repr__(self):
return "{}(v={})".format(type(self).__name__, self.volume)

class Tetrahedron(Polyhedron):
"Self dual, space-filler with octahedron"

def __init__(self, v=1):
self.volume = v
self.edges, self.vertexes, self.faces = (6, 4, 4)

class Cube(Polyhedron):
"Dual of Octahedron, space-filler"

def __init__(self, v=3):
self.volume = v
self.edges, self.vertexes, self.faces = (12, 8, 6)

class Octahedron(Polyhedron):
"Dual of Cube, space-filler with tetrahedron"

def __init__(self, v=4):
self.volume = v
self.edges, self.vertexes, self.faces = (12, 6, 8)

class RhDodecahedron(Polyhedron):
"Dual of Cuboctahedron, space-filler"

def __init__(self, v=6):
self.volume = v
self.edges, self.vertexes, self.faces = (24, 14, 12)

class Cuboctahedron(Polyhedron):
"Dual of Rh Dodecahedron"

def __init__(self, v=20):
self.volume = v
self.edges, self.vertexes, self.faces = (24, 12, 14)

mypolys = (Tetrahedron(), Cuboctahedron(), Octahedron(), Cube())
volume_order = sorted(mypolys)
print(volume_order)

from operator import attrgetter
name = attrgetter("__class_

[Edu-sig] Python for Microprocessors

2018-07-29 Thread kirby urner
I'm just now perusing Steve Holden's slides for the first time, in PDF
format, regarding the state of the art when it comes to Pythonic hardware
(e.g. Micro:bit):

https://github.com/holdenweb/PyConIE2017/blob/master/MicroPythonEcosystem.pdf

I find this illuminating.  Steve has a long fascination with hardware
programming.

Also, I'm just putting some finishing touches on a Medium piece
(unrestricted) advertising the capabilities of the Raspberry Pi platform
(not Python specific, but certainly Python-linked):

https://medium.com/@kirbyurner/summer-camp-computing-some-fun-in-the-sun-95c4efd5af94

(the top picture shows a Pi Lab the same Steve Holden set up in Portland
some years ago, helping to catalyze our little subculture).

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] the state of Vpython

2018-07-20 Thread kirby urner
edu-sig has a long history with Visual Python, going back to Pygeo (Arthur
Siegel's project, pygeo.sourceforge.net/ ) any my own work with that
package.

What's the state of the art today?  In a word: Glowscript.

Here's a good example.  I see dates on the source code suggesting the site
is maintained and evolving.

https://bphilhour.trinket.io/physics-through-glowscript-an-introductory-course#/1-introduction-objects-parameters-and-the-3d-environment/welcome-and-introduction

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] False alarms?

2018-07-17 Thread kirby urner
Wow that'd be something to have some student / faculty take advantage of
the schema.org templates for sharing topics.

The School Server:  Do We Have One?

At the college level you often get faculty / students building and tending
servers of various types, and otherwise assisting in the management of
computing infrastructure used throughout the school.

Were I to design a new school from scratch, I would assume a central store
where theatrical events, sporting events, student and faculty recordings in
many categories, could be collected and also to some extent shared with
alumni.  This describes my relationship to my university (as an alum, I
have access to various services), but not to my high school.

I don't think many millennials have a way to log in to their old high
schools, as alumni, to view debates, presentations, show & tell
experiences, nor even a school paper.  There's a home page perhaps,
something hosted at the district level, and a way to drill down for
institutional information, but don't expect to watch last week's football
game on-line.

Python.org is exemplary in documenting ongoing conversations and
administrative processes through discussion groups.  In the interests of
transparency, many of these are public.

Note:  through Facebook and informal networks sharing digital assets
privately, a well-connected alum may nevertheless gain access to a lot of
information, there's just no in-house dedicated effort towards maintaining
such services, meaning faculty and students are less likely to experience
real world responsibilities, such as for maintaining the Chess Club server
(which is a lot about community outreach and actually teaching chess, not
just giving students ways to play each other).

Impressions from OSCON

I keep coming back to what's happened in statistics, which in my high
school years was an elective on par with trigonometry.  If you wanted to
augment your required math with electives, you could add stats and trig to
the menu (I did).  Otherwise, just do Algebra 1, Geometry, Algebra 2
(Pre-Calc) and Calc.

Statistics turned into Machine Learning in a lot of ways.  Tensorflow 1.9
is more like Pytorch these days in allowing us to skirt the "old way" of
doing it:  at a more meta level.  That way is still there, and important,
but Google is these days pressing ahead with:

# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras

Note how each of these 5 tutorials (as of July-August 2018) has a link in
the upper left to a corresponding Jupyter Notebook, dubbed Colab:

https://www.tensorflow.org/tutorials/

This is what OSCON tutorials look like today, with the speaker mentioning
how you rarely need more then twelves lines of code in a code cell.
Programming no longer has to mean writing lengthy scripts.  Mathematica
helped pave the way for these high level APIs.

All of which takes me back to my suggestion that we beef up the stats
aspect of high school and use it as a place to expose students to some of
these higher level APIs, giving them the flavor.[1]  Get used to managing
datasets, not just noodling through one little computation at a time.

Speaking of what's fun for kids, check out this drawing program, which
tries to guess what you're drawing ahead of time.  The algorithm is no just
looking the the cumulative graphic, but at the order in which you draw its
parts, as when writing a Chinese character.

https://quickdraw.withgoogle.com/

Have your sound turned on, as it talks to you.

Kirby

[1]  https://mail.python.org/pipermail/edu-sig/2018-April/011825.html





On Mon, Jul 16, 2018 at 6:37 PM, Wes Turner  wrote:

> - [ ] Develop URIs for K12CS framework, Common Core, Khan Academy concepts
>
>   - [ ] Encourage educational CreativeWork creators to include schema.org
> markup in their HTML:
>
>   - schema.org/about
>   - schema.org/educationalAlignment .url @id
>   - https://schema.org/educationalFramework
>
> - [ ] Develop mappings between concept/curriculum/#head-ing URIs
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] excerpt from real world python class

2018-07-13 Thread kirby urner
When I'm not doing exotic Martian Math summer school, sharing weird
Portland math no one knows if not an American literature buff (1900s New
England Transcendentalism), I'm teaching night school Intro to Python, in
California, or nationwide, online.

Tonight I was saying that whereas Python is named for Monty Python, I think
Greek Mythology probably has a long half-life (it's not either/or anyway),
so I'm into exploring Vaults of Parnassus etc., not a new idea among
Pythonistas (to link to Greek myths).

This is to explain some of the comments.

>From tonight's summary meetup (last session, 10 of 10):

=

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 12 16:39:32 2018

@author: Kirby Urner
"""

class I:
"""
a goofy goofy I

normally Pythonistas say self not me, but hey,
it's just a placeholder.  Free country.
"""

def __init__(me):
me.stomach = [ ] # empty (subclasses use it)
me.energy = 100

def __repr__(self):
return "I live at {} on Memory Lane".format(id(self))

def __str__(me):
return "Well hello, I'm a self"

def selfie(me):
"Click!"
return me

def __enter__(me):
"""
context manager I am
"""
return me.selfie() # same as return self

def __exit__(me, *oops):
if oops[0]:
return False  # woopsy, sorry about that
return True

def __del__(me):
print("I now have one less refcount!")

if __name__ == "__main__":
with I() as me:
print(me)
print([me])

# me sticks around even after context ends

other = I()
print(other, "too")
print([other])

del me
del other

==

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 12 16:56:25 2018

@author: kurner
"""

from selfcentered import I

class Foe(I):
"""
The mythical Python lived under Mt. Parnassus (Παρνασσός)
and its breath (?) gave the Oracle of Delphi her powers
of diagnosis and prognosis

https://en.wikipedia.org/wiki/Pythia
"""

def __del__(self):
# https://en.wikipedia.org/wiki/Athena_Parthenos
print("Apollo thinks I'm dead, but I escaped to Nashville")
global selfcentered
import selfcentered
selfcentered.Python = self  # hide out in another module

class Hero(I):
"""
Apollo is supposed to have slain the Python under Mt. Parnassus
"""

def __init__(self):
super().__init__()
print("A hero is born!")

def eat(self, food : str):
if not type(food) == str:
raise ValueError
self.stomach += [food]  # yum!
self.energy += 10

def slay(self):
global Python
if self.energy:
del Python
print("Foe slain")
else:
print("I'm too weary to fight.  Feed me!")
self.__spend_energy()

def __spend_energy(self):
if self.energy:
self.energy = (self.energy - 10
if self.energy >= 10
else 0)
if len(self.stomach):
print("Digesting {}".format(self.stomach.pop(0)))

def seek(self):
print("seeking foe")
self.__spend_energy()

def __repr__(self):
return "< Hero Energy:{} Stomach:{} >".\
format(self.energy, len(self.stomach))


if __name__ == "__main__":
Python = Foe()  # Foe
Apollo = Hero() # Hero

Apollo.eat("Manly Meal")
print(Apollo.stomach)
Hero.seek(Apollo)
Apollo.seek()
print(repr(Apollo))
Apollo.eat("Rats")
Apollo.eat("Beer")
Apollo.seek()
Apollo.seek()
Apollo.seek()
Apollo.seek()
print(repr(Apollo))
Apollo.slay()
print(repr(Apollo))
Apollo._Hero__spend_energy() # remember name mangling?
print(repr(Apollo))
print("Good bye Apollo")
del Apollo

===
OUTPUT:

runfile('/Users/mac/Documents/pyt-pr/Session10/heroic_story.py',
wdir='/Users/mac/Documents/pyt-pr/Session10')
A hero is born!
['Manly Meal']
seeking foe
Digesting Manly Meal
seeking foe
< Hero Energy:90 Stomach:0 >
seeking foe
Digesting Rats
seeking foe
Digesting Beer
seeking foe
seeking foe
< Hero Energy:70 Stomach:0 >
Apollo thinks I'm dead, but I escaped to Nashville
Foe slain
< Hero Energy:60 Stomach:0 >
< Hero Energy:50 Stomach:0 >
Good bye Apollo
I now have one less refcount!

selfcentered.Python
Out[26]: I live at 4892551320 on Memory Lane



"""LAB 3 UNTIL 10:10"""
Out[20]: 'LAB 3 UNTIL 10:10'

class Dog:
def bark(self):
print("Bark!")


dog = Dog()

dog.bark()
Bark!

Dog.bark(dog)
Bark!
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] False alarms?

2018-07-11 Thread kirby urner
On Wed, Jul 11, 2018 at 5:19 AM, Sergio Rojas  wrote:

>
>  Kirby, Definitely good points to invest a couple of beers cerebrating
> about
> them regarding the teaching and learning process and how to do better.
>  Thanks for sharing.
>
> Sergio
>


​Definitely worth some beers to figure out a master plan for improving
the educational experience of students everywhere.

With my so-called Martian Math, I have a market advantage in
that I've got some interesting content that practically no one else
is taking advantage of, yet there's a large public literature behind
it.

I told my summer campers they were entering a goldmine of
of raw material for possible research projects down the road,
which they could be pretty sure was fresh and new to their
teachers and peers.

Kirby
​



>
> ​Excellent question and highly relevant to bring up Common Core Math
> Standards.
> I understand a physicist dude came up with it originally?​  Seems I saw
> that somewhere.
>
> My attitude is CCMS is a bare minimum, a super stripped down
> almost-starving
> diet that sets a floor.  Faculties are free to pack it out with a whole
> lot more if they
> wish: golden ratio, polyhedrons (in vector spaces), unicode, and of course
> bases
> other than 10.
>
> CCMS is not a ceiling and was never intended as such.  We could treat it
> as about
> 10% of what we hope to cover -- under the heading of CS (I'm not sure math
> teachers will have the time, given they don't have the millisecond
> turnaround
> times we do, with our computers).
>
> Kirby
>
>
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] False alarms?

2018-07-10 Thread kirby urner
On Tue, Jul 10, 2018 at 11:51 AM, Sergio Rojas  wrote:

>  Okey-dokey, Kirby. Nice exposition, including the web links.
> To explore this issue a bit further, how, in your view,
>  the Common Core State Standards (http://www.corestandards.org/)
> fit in the CS call at schools?
>
> The standard points what perhaps is already being implemented as
> an operational way to approach it:
> from page 7 of
> http://www.corestandards.org/wp-content/uploads/Math_Standards1.pdf
>
>


> 5 Use appropriate tools strategically.
> Mathematically proficient students consider the available tools when
> solving a mathematical problem. These tools might include pencil
> and paper, concrete models, a ruler, a protractor, a calculator,
> a spreadsheet, a computer algebra system,
> a statistical package, or dynamic geometry software.
>
>
>



​Excellent question and highly relevant to bring up Common Core Math
Standards.
I understand a physicist dude came up with it originally?​  Seems I saw
that somewhere.

My attitude is CCMS is a bare minimum, a super stripped down
almost-starving
diet that sets a floor.  Faculties are free to pack it out with a whole lot
more if they
wish: golden ratio, polyhedrons (in vector spaces), unicode, and of course
bases
other than 10.

CCMS is not a ceiling and was never intended as such.  We could treat it as
about
10% of what we hope to cover -- under the heading of CS (I'm not sure math
teachers will have the time, given they don't have the millisecond
turnaround
times we do, with our computers).

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] False alarms?

2018-07-10 Thread kirby urner
Hi Sergio --

Per this article, with so many states and no national curriculum (I don't
advocate for one), it's tough to generalize about US schools:

https://www.theatlantic.com/education/archive/2018/07/americas-schools/564413/

Now, to generalize :-D

The mathematics classroom was rarely also a computer lab.  If the school
has a computer lab, that's usually a separate facility and they learn
business applications and typing, rarely much programming, until rather
recently.

Today, schools likely have Chromebooks in large charging cabinets on
rollers.  Fewer schools give out Chromebooks to each student but that's the
trend, perhaps from 6th or 7th grade up.

The mathematics curriculum has never integrated any programming as there's
still that sense that programming takes years to learn and would be a huge
detour.  Those of us more familiar with the state of the art don't see it
that way.

You're right that Mathematica paved the way for a small subculture and
I-Python, Sage, Jupyter Notebooks, SymPy do feature in some US schools, but
very few.

Rather than integrate mathematics and learning to code, the strong belief
is we need to keep math and computer science separated, which means
teaching a lot of things twice, given the Venn Diagram shows large overlap.

Your book, which I've been reading, takes the more integrated approach that
I favor.

Math teachers are in a tough position I think, as a lot of the mathy
content that students find most attractive is being placed in another
subject area.

I have my opinions about all this, as a former high school math teacher
turned applications programmer and teacher-trainer.

https://medium.com/@kirbyurner/the-plight-of-high-school-math-teachers-c0faf0a6efe6

Finding a lot of computer science teachers in a hurry is the name of the
game right now, and lots of educators are selling on ramp teacher training
programs.  That's becoming a big business.

I expect many with a math teaching background are currently migrating to
computer science, so in some sense my desire for better integration is
being fulfilled.  Some of this on ramp programs teach a language called
Pyret, which we're told is the better way to go.

Kirby




On Tue, Jul 10, 2018 at 5:13 AM, Sergio Rojas  wrote:

>
> >  here's a blog post raising the alarm
> > that Python (among others) is "completely incompatible with mathematics".
> >
> >
> > https://blogs.ams.org/matheducation/2017/01/09/
> integrating-computer-science-in-math-the-potential-is-
> great-but-so-are-the-risks/
>
>
>
> I get lost reading the referred blog post. I was
> under the impression that the ideas presented in the
> post were already fully discussed back in the 90's,
> when Mathematica was getting its way into the
> classroom at US schools. That things like "x = x + x"
> were already familiar to teachers.
>
> In fact, I was thinking of an open source alternative to Mathematica
> when writing the book on Prealgebra via Python Programming
> (https://www.researchgate.net/publication/325473565), with the
> advantage that Python can be used for intensive computing task as
> well as for symbolic (algebraic) computations (like mathematica)
> via SymPy.
>
> I was under the idea that the Mathematica team has already shaped and
> polished the road. I can see that I was wrong. It is still very, very
> rough (much more than the first draft of my book).
>
> Sergio
>
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Editors/IDEs for teaching

2018-07-09 Thread kirby urner
On Mon, Jul 9, 2018 at 7:46 AM, Andrew Harrington  wrote:

> Not a full IDE, but the fine free CS1-ish text
> https://runestone.academy/runestone/static/thinkcspy/index.html
> has the ability to enter Python directly into the browser and run it.
>
>
​Awesome!

+1
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] false alarms?

2018-07-06 Thread kirby urner
Apropos of earlier discussions that
​assignment in ​
Python is about giving names to objects,
​and ​
not putting those objects in boxes, here's a blog post raising the alarm
that Python (among others) is "completely incompatible with mathematics".

https://blogs.ams.org/matheducation/2017/01/09/integrating-computer-science-in-math-the-potential-is-great-but-so-are-the-risks/

Excerpt:

===

Making matters worse, programming languages like Java, JavaScript, Python,
Scratch and Alice all rely on the concept of assignment. Assignment means
that a value is “stored in a box”, and that the value in that box can be
changed. Here’s a simple JavaScript program that demonstrates this:

x = 10

x = x + 2

The first line of code assigns the value 10 into a box named “x”. The
second line reads the value back out, adds 2, and assigns the new value
back into x. When the program finishes, x contains the value 12.
Unfortunately, the semantics and syntax are completely incompatible with
mathematics! In math, names are given to values, not boxes.

===

Following Kenneth Iverson, I think pre-computer math notations (MN) could
benefit a lot from an infusion of ideas from these newer executable
languages.

He turns around the criticism of x = x + 2 by pointing out the ambiguity on
in conventional math notation (MN):

===
MN uses the symbol = for a relation, but also uses it for assignment, as in
the expression (Let) x=3. Again, to denote these two distinct notions
without ambiguity, programming languages use distinct notation (that
usually includes the symbol =), as in := (in ALGOL), and =: (in J).
===

http://www.jsoftware.com/papers/camn.htm

Drawing a line in the sand and saying "on this side is programming" whereas
"on this other side is math notation", seems more a bureaucratic maneuver
than anything.

There's a protection racket going on where self-appointed authorities are
planning to warn us against "doing it wrong" i.e. not their way.  Many
bogus certifications will follow.  Not that we shouldn't have standards.
The question is who's.

math = math + cs

Kirby
​
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Editors/IDEs for teaching

2018-07-05 Thread kirby urner
​Regarding Atom.io editor for Python (and other languages), I'm just now
discovering the Hydrogen plug-in.

This allows highlighting contiguous lines in a script and ​treating this as
a cell, as if in a Jupyter Notebook (but we're in a normal program).

The output inserts directly below.  Here's a screen shot:

https://flic.kr/p/27KsgFG
Editor split in two columns with in-line Jupyter-like output interleaved

I found this Youtube showing the user experience:

https://youtu.be/VcDbxEV-OI0
Learn Jupyter Notebooks (pt.1a) Hydrogen with Atom
​by Mark Jay​

As with Jupyter, you can also get LaTex symbolic output with this feature.
Still exploring.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Editors/IDEs for teaching

2018-07-04 Thread kirby urner
>
> https://github.com/quobit/awesome-python-in-education/
> blob/master/README.md#ides
> lists a bunch of IDEs, but not with such a useful table of structured
> criteria.
>
>
​Great listing of resources!

Yes, I like using the #%% feature to bracket sections of a script, used
that tonight.  I failed to find much time for Atom, maybe next time.

I've found myself back in Atom recently because I'm learning Rust, at least
to a "getting my feet wet" level.   Atom has the needed color coding.

Which reminds me of an important distinction between IDEs:

Those that focus on one language versus IDEs suitable for polyglots (the
above listing has some of each).

Sometimes the best intro courses hop around among languages, highlighting
sameness and differences.

I enjoyed a great one at Princeton like that, which had us coding in PL/1,
FORTRAN, APL, SNOBOL, an Assembly and I'm forgetting what else.

That was in the 1970s (!) so of course the lineup would have changed
immensely.

Python front burner, maybe look at two others back burner?  More like
Harvard's CS50.

https://youtu.be/n_8zxTH7SvA

Sometimes even if just looking at Python, one might go with at least two
IDEs as a minimum, perhaps one dedicated to Python, one more general
purpose.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Editors/IDEs for teaching

2018-07-03 Thread kirby urner
On Tue, Jul 3, 2018 at 12:45 PM, Andre Roberge 
wrote:

>
>
> On Tue, Jul 3, 2018 at 3:59 PM kirby urner  wrote:
>
>>
>> I use Spyder in my adult beginner Python classes. I like the integrated
>> REPL (not just a window to Terminal) and the I-Python console.
>>
>
>
> ​Looking at some old emails, about 3 years ago I had concluded that Spyder
> would have been my first choice too, because of what you mentioned. I also
> liked the integrated help.  However, I would not describe it as an editor
> (or IDE) whose primary purpose was for teaching, but rather designed with
> data scientists in mind.  I think it might be a good choice for CS 101
> students (to use the terminology I used previously) or for a motivated
> teacher who can be physically present to help students with it.
> ​
>

​Yes I agree that Spyder is not primarily for teaching. In making the job
of coding easier, I good IDE inevitably serves a teaching function.

I teach Python in two ways:  BYOD (students have their own computers) and
spin up a desktop in the cloud somewhere.

The Anaconda distro suggests itself for BYOD because of its support of
grabbing additional packages as well as integrating lots of tools.

In the spin up a desktop courses, I've used Eclipse (O'Reilly School) and
more recently Wing (ONLC).

What I tell all my students is choice of IDE can be personal, a matter of
taste, and they my want to jump around. I mention a bunch of them and
demonstrate at least a couple near the start of my course, but then settle
into using one most of all.  That's been Spyder for the last few years.

I'm enjoying Atom these days.  I'm planning on sharing it tonight in fact
(a 7th meetup of 10 for SAISOFT).

What I like about Spyder is it's no cost and continues to improve.  I like
being able to clear the REPL at any time, also to %reset (wipe memory).  In
terms of students watching my screen in real time, I've become most
comfortable with Spyder, but who knows if this will change.

I have the programming window and REPL side-by-side vertically.  I've got
some Youtubes about it.  E.g.:

https://youtu.be/yK0LrfQFdQY

(10 minute video about going from Codesters to Spyder, doesn't get to
Spyder until around 3:52).

I do not think my content, style, choice of tools, is in any sense "best"
as circumstances and client needs vary, not to mention instructor
capabilities.

​

>
>> Also, I'm a fan of the Anaconda distro of Python which makes it easy to
>> jump into Jupyter Notebooks, an introductory topic in my courses.
>>
>
> ​I also like Jupyter Notebooks, but I see them more as a tool for
> producing teaching (or research) material, than for a platform for students
> to learn Python. I consider the ability to save a program as a .py file
> something essential in an editor for students.
>

​Yes, many ways to slice through the material.  I just finished a summer
camp in a computer lab where my primary objective was to walk them through
cloning a git repo on a mac (git already installed) and then experimenting
with Markdown in the Jupyter Notebooks they found therein.  Add some
pictures from Flickr.  Add a few links.

I did draw their attention to the Python code cells and encouraged them to
experiment by making changes to existing code.  One of the campers tried to
get a Wolfram Alpha API working through his Notebook however that required
dependencies we didn't have permission to install apparently.  These
desktops were provided by the college hosting the summer camp (Reed in
Portland).  I talked them into putting Anaconda on.

FYI, the repo in question:
https://github.com/4dsolutions/MartianMath

These were middle schoolers, about 15.  I had an assistant instructor but
he was mostly involved with C6XTY projects (unplugged).
​

>
> The last time I wanted to do a major update to my Anaconda distro on
> Windows, I was shocked to learn that the recommended way was not going to
> work (I believe it was due to the way that Anaconda was stuffing too much
> stuff on the PATH environment variable which made it not possible to do an
> upgrade to include a newer Python version).  I may have got the details
> wrong, but I do remember being severely disappointed by the way it worked -
> as I had gotten really fond of its super-battery included philosophy which
> made it so much easier to install some packages on Windows...
>
>
​Anaconda is a moving target and the experience on Windows / Mac / Linux
varies some.  Still, it's a viable alternative to the canonical Python.org
distro.

Jupyter Notebooks represents a kind of "literate programming" (Knuth) where
what you're showing with code may indeed not so much be about teaching the
language itself.  We're more surveying the contemporary workplace, looking
at tools that might already be used, or might be soon introduced.

In this summer school use case, we we

Re: [Edu-sig] Editors/IDEs for teaching

2018-07-03 Thread kirby urner
I use Spyder in my adult beginner Python classes. I like the integrated
REPL (not just a window to Terminal) and the I-Python console.

Also, I'm a fan of the Anaconda distro of Python which makes it easy to
jump into Jupyter Notebooks, an introductory topic in my courses.

Given Jupyter grew out of I-Python, there's a lot of commonalities and
integration, especially around %magic commands.

Spyder is comparable to Wing 101 in its capabilities.

Kirby



Editors / IDEs :
>
> * IDLE: included with Python. Intended for everyone.
> * Mu (https://codewith.mu/). Primarily intended for young learners and
> hobbyists.
> * Thonny. (http://thonny.org/) I am guessing that it is primarily
> intended for CS 101.
> * Wing 101 (https://wingware.com/downloads/wingide-101) Primarily
> intended for CS 101.
> * PyCharm Edu (https://www.jetbrains.com/pycharm-edu/) Primarily intended
> for CS 101.
>
> I am not looking for web-based solutions [otherwise, I would have had
> included Reeborg's World ;-)] and do not want to include obsolete or no
> longer maintained software (like rur-ple, the precursor to Reeborg's World.)
>
> Best,
>
> André
>
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-07-02 Thread kirby urner
Thanks for your persistence on this Andre.  I agree with you that this is a
serious bug.

Curriculum writers down the road will steer clear of Python's turtle if
it's not up to responding sanely to left and right.

Our loyalty should be to teachers and teaching material developers in the
future, not as much to prior editions with unfortunate workarounds.

Kirby



On Wed, Jun 27, 2018 at 6:29 PM, Andre Roberge 
wrote:

>
>
> On Mon, Jun 18, 2018 at 1:50 PM Jurgis Pralgauskis <
> jurgis.pralgaus...@gmail.com> wrote:
>
>> Ok, I could test it :)
>>
>>
>> Should I wait for some commit and comment results on the issues site or
>> how...?
>>
>
> ​Jurgis: Could you just apply the patch I submitted locally and test it?
>
> Or would anyone else volunteer to test it?  Obviously, I can provide an
> independent test of my own contribution. :-)​
>
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] creative unplugged activities in computer science classes

2018-06-25 Thread kirby urner
On Sun, Jun 24, 2018 at 8:13 AM, Wes Turner  wrote:

> > 4. Create a visualization
>
> The Khan Academy Computer Programming "Intro to JS" videos and exercises
> are done with ProcessingJS for visualizations:
> https://www.khanacademy.org/computing/computer-programming
>
>
​Glad to see ProcessingJS mentioned.  Arduino programming inherits from
Processing model also.

One of the more effective subcultures I'm aware of, vis-a-vis Learning to
Code, is spearheaded by Dan Shiffman of Coding Train fame, a ProcessingJS
guru:

http://worldgame.blogspot.com/2018/03/youtube-teachers.html  (links to
Dan's Youtube channel)

Glad to see Unplugged activities getting plugged (advertised).  New Zealand
an early player.

https://www.csunplugged.org/en/

Also happy to see Vilnius in the edu-sig news feed, having attended a
EuroPython there.  I became a Vilnius fan.

http://worldgame.blogspot.com/2007/07/vilnius.html

Kirby

​

>
>
> On Sunday, June 24, 2018, Wes Turner  wrote:
>
>>
>>
>> On Sunday, June 24, 2018,  wrote:
>>
>>> Dear Python educators,
>>>
>>>
>>>
>>> teaching Python includes explaining technical facets of the programming
>>> language and initiating and scaffolding hands-on programming exercises.
>>>
>>> However, especially  if the object of the course is to develop
>>> “computational thinking” and to get a deeper understanding what computer
>>> science is, the curriculum might contain “unplugged” activities without a
>>> computer.
>>>
>>> What do you think about unplugged activities challenging creativity? I
>>> would like to advertise a questionnaire, which is part of an international
>>> study on this type of activities in computer science education.
>>>
>>> https://goo.gl/forms/seYGUlsKHxyiqqnX2
>>>
>>> The results will be presented in August 2018 at Constructionism in
>>> Vilnius (Lithuania) and will be available to everyone
>>> http://www.constructionism2018.fsf.vu.lt/ .
>>>
>>>
>>>
>>> Thank you and best wishes
>>>
>>>
>>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-19 Thread kirby urner
Hi Sergio --

Thanks for taking a look at the Q-ray coordinates!

You're right about many bridges to crystallography in this neighborhood.

​I'm part of a tiny subculture that came up with Q-rays in a listserv long
ago.

http://mathforum.org/library/view/6236.html

It's not that I'm the only one familiar with the ideas or that I'm the only
contributor, just I know of no one else bringing it to the attention of a
pre-college class, and I do that only rarely.

The connection with Python is a Quadray class is implemented therein.  My
friend Tom has them in C++ (see Wikipedia).

https://github.com/4dsolutions/Python5/blob/master/QuadraysJN.ipynb

I've also dabbled in a Clojure version.

https://github.com/4dsolutions/synmods/blob/master/qrays.clj

I worked with Quaternions a long time ago, to do a rotating cube applet,
but then applets became a deprecated technology, much to everyone's
surprise and consternation.

http://4dsolutions.net/ocn/oopalgebra.html

Kirby
​

On Tue, Jun 19, 2018 at 12:14 PM, Sergio Rojas  wrote:


> Kirby,
>
> Looking way far in the back of my head,
> the closest thing (to the inspirational drawings of
> your notebook) I could recover
> is what is called fundamental lattice structures of
> solid state physics. Not sure, but in there
> they might use your coordinate system to better describe
> structures of crystals.
> The book by Kittel, pg 27 of the 8th Edition, has some stuff on it.
>
> Other object in that sense is the Quaternion thing
>   https://en.wikipedia.org/wiki/Quaternion
>
> Better stop here, I am getting hurt ...
>
> Sergio
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-19 Thread kirby urner
On Tue, Jun 19, 2018 at 11:20 AM, Andre Roberge 
wrote:

> Is this Python's edu-sig or Monty Python's philosophers club?  ;-) ;-) ;-)
>
>
​I do think we're branching out to discuss coordinate systems more
generally, as a perennial feature of pedagogy.

These more general concerns are distinct from turtle.py in particular.

I hope contributors are not shy about continuing the higher level
discussions.
​

> Anyone on this list could probably do the following in less than one
> minute...
>
>
​Yes, I just ran the following:

>>> turtle.setworldcoordinates(0, -200, 400, 0)
>>> turtle.forward(100)
>>> turtle.right(90)
>>> turtle.forward(100)
>>> turtle.left(90)
>>> turtle.forward(100)
>>>

Here's the resulting graphic output:

https://flic.kr/p/28i3cDY

However in this test, I did not isolate the problem.  The turtle turns to
its own right and then its own left.

I'm assuming lower left is (0, -200) and upper right is (400, 0) i.e. Y
still increases as we go vertically towards the top.

I should change that...

Lets make Y increasingly positive as we go down the screen.

>>> turtle.setworldcoordinates(0,200,400,0)
>>> turtle.forward(100)
>>> turtle.left(90)
>>> turtle.forward(100)
>>> turtle.right(90)
>>> turtle.forward(100)
>>> turtle.right(90)

Indeed, now I see the problem.  The turtle no longer obeys it's own
viewpoint but turns oppositely to what I command.

Here's the graphic output this time:

https://flic.kr/p/26ZJmQ2


Kirby
​
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-19 Thread kirby urner
On Tue, Jun 19, 2018 at 7:27 AM, Sergio Rojas  wrote:

>
>
> Some issues to keep in mind:
>
> From the The Feynman Lectures on Physics:
>
> http://www.feynmanlectures.caltech.edu/I_52.html
> """
> Fig. 52–1(b)! The first molecule, the one that comes from the living
> thing, is called L-alanine. The other one, which is the same chemically,
> in that it has the same kinds of atoms and the same connections of the
> atoms, is a “right-hand” molecule, compared with the “left-hand”
> L-alanine, and it is called D-alanine.
> ...
> ...
> So it looks as though the phenomena of life permit a distinction between
> "right" and "left," ...
> """
>
>
​Yes, a very excellent suggestion and apropos in this context, Sergio.

The Feynman piece is fascinating.  I like that he features a "Martian" (see
below).

Congruent vs. Chiral:

I hang out on some math teacher web groups (mostly on Facebook) and one
topic that comes up a lot is "congruence".

Interestingly, the math concept of "congruence" teaches us to overlook or
ignore "chirality" or handedness in structures, despite these enantiomers
having completely different chemical properties.​

We would say the left hand is congruent to the right hand in a math class.

I downloaded the PDF of your book and am reading it.  Impressive!

Mixing math and programming and deriving the benefits of synergy has been
one of my themes as well.

Regarding coordinate systems, I'm probably the only teacher to use what I
call Quadrays in the classroom.  Indeed, next week I'll be sharing a summer
camp course in "Martian Math" with some Silicon Forest kids that features
this alternative coordinate system, with four basis rays from the center of
a regular tetrahedron to its four corners, using positive 4-tuples.

All points in space are linear combinations of these four basis vectors. I
have Python code for converting back and forth to XYZ.  The centers of
closest packed spheres in the CCP all have positive whole number
coordinates.

https://en.wikipedia.org/wiki/Quadray_coordinates
https://github.com/4dsolutions/Python5/blob/master/Generating%20the%20FCC.ipynb

I tell them this is what Martians use, acknowledging this is purely science
fiction, and suggest that comparing and contrasting a conventional
apparatus with something alien (unfamiliar) actually helps students achieve
a deeper understanding of the convention.

Martians also use triangles and tetrahedrons to model 2nd and 3rd powering
such that 3 x 3 x 3 is a tetrahedron of 27, not a cube of 27.

We have a constant for going back and forth between XYZ cubic volumes and
IVM tetra volumes.

http://www.4dsolutions.net/satacad/martianmath/toc.html  (from my previous
iteration of this class)



> Other Related links:
>https://phys.org/news/2014-10-handedness-life.html
>http://www.iflscience.com/space/why-life-left-handed-answer-stars/
>
>
​Yes very useful.  Looking for chemical signatures in space leads me to
Harold Kroto's discovery of C60 and its subsequent analysis and synthesis
as a topic.

https://youtu.be/yZ8JDDnyxC4  (another link re chirality)

Thanks again!

Kirby

​

> Sergio
> Check out the free first draft of the book:
>  Prealgebra via Python Programming
>  https://www.researchgate.net/publication/325473565
>  https://github.com/rojassergio/Prealgebra-via-Python-Programming
> ___
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-18 Thread kirby urner
On Mon, Jun 18, 2018 at 9:54 AM, Kevin Cole <
kevin.c...@novawebdevelopment.org> wrote:

> Sticking my nose in where it don't belong. ;-) But that's never stopped me
> before. ;-)
>
>
​Hi Kevin.  I for one welcome your comments as I do think teachers need to
prepare students for more than one way of doing coordinate systems.

As you well know, and point out, in maths we almost always make the
positives go to the right and the negatives to the left (number line).

Then we add a 2nd number line going up and down, with positives increasing
in magnitude going up and negatives getting bigger going down.

This arrangement of two numbered lines considered "most normal" i.e. this
schema is rather ubiquitous and must be considered something of a home base
in classroom projects.

Where to put the origin (0,0) is another question and is usually

(A) at the lower left of the plot (if we don't need all four quadrants) or
(B) in the middle (if we do need all quadrants), like when doing a unit
circle.

However if you walk around to the back and look from the other side... my
right is your left and so on -- these are terms relative to a point of
view, not to the object in front of us, which is where the confusion often
begins.  Who's left?

Stage left means what again?  It's the actor's left, not the audience's
left.  Theater practice is another place to absorb geometry.  The screen is
a kind of stage after all, with sprites = puppets.  I always tell my
Scratch students that programming is a kind of theater (stuff follows a
script, objects i.e. actors, agents, sprites, do stuff i.e. act).

https://www.sewwhatinc.com/blog/wp-content/uploads/2010/02/stage_diagram1.jpg

Computer graphics (Blender et al) reintroduces the camera or viewpoint,
which is often missing from elementary maths textbooks.

Math texts don't believe in talking about an observer for some reason, or
multiple observers.  I expect the influence of computer science to be a
positive influence in helping address that blind spot over time.

MIT Scratch, by far the most popular way to introduce programming in my
neck of the woods (Silicon Forest), puts (0,0) in the middle, Y up, X right.

Also, should we make the Z axis go into the page or stay on the page
perpendicular to X?  Again, viewpoint matters.

Where is the viewer in this picture, and in what direction is the viewer
looking?  Important questions!

Getting off the XY plane to XYZ is always the next step in maths, including
in computer graphics.

We may introduce latitude and longitude at this point, along with spherical
coordinates, in addition to XYZ.

I've used POV-Ray in some of my classes, and certainly for my own Python
projects.

http://4dsolutions.net/ocn/pymath.html

In POV-Ray the positive Z-axis points into the screen and Y goes towards
the top of the screen, matching most textbooks that stick to X and Y.

When I teach Codesters (Python) in the classroom, I always warn them that
when they get to Codepen.io later (where we use HTML, SVG etc), the
coordinate system will flip and they'll hear a lot more about H and W
(height and width).

We'll also talk a lot more about pixels (cells) and the level of resolution
(frequency) which, in a DGGS (geospatial data system) might be hexagonal
and pentagonal.

http://i.stack.imgur.com/UtStp.jpg

https://www.eat-the-planet.com/wp-content/uploads/2017/07/tile_resources2_comp.png

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-17 Thread kirby urner
>
>
>>
>> performs as expected out of the box right?
>>
>
> ​Yes, it does. BUT, if you set the world coordinates like Jurgis reported,
> then left and right are inverted. There's an easy fix ... but it has been
> rejected.​
>
>
​OK.  Thanks for the clarification.  I had no idea.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] turtle coordinates: Y increase downards - as in most graphics API?

2018-06-17 Thread kirby urner
Any Ideas?
> Thanks :)
> --
>


​Wow I didn't know about this issue.

Just

import turtle
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)

performs as expected out of the box right?  Forward is in the direction the
turtle is facing and left and right are the turtle's own front paws.  We're
looking down on said turtle.

https://flic.kr/p/Lb4mUf  (warning: URL is case sensitive)

I gather some have a preference for (0,0) as upper left versus smack dab in
the middle of the screen with X right and Y up?

Codesters and Scratch follow the (0,0) in the middle convention.  That's
how math textbooks do it.

HTML Canvas object is irrelevant.  Resistance is futile.  Just kidding.

Would be good to have a global setting, just like for cubic vs. tetra
volumes.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Collaboratively developing OER Python textbooks.

2018-06-14 Thread kirby urner
I notice the worries about dragons expressed here:

http://www.openbookproject.net/books/StudentCSP/CSPRepeatNumbers/range.html

The type versus function distinction is too big an idea to get into here.
Skulpt is 2.x flavored for sure.  We notice that in Codesters as well.

This looks like an excellent resource regardless and I plan on sharing a
link to this book in class tonight, in part just to encourage a culture
wherein collaboration on teaching texts is more the norm than the exception.

Good work.

On another topic (but related to co-authoring teaching materials):

When do teachers think it's appropriate to start in with LaTeX?  Given it
works in Jupyter Notebooks between $s, without downloading anything fancy,
I'm thinking no later than 9th grade?  That's assuming the school is using
Jupyter Notebooks in 9th grade.  I'd hate to imagine a school that isn't
(just kidding, I know that most don't, no need to imagine).

I'm far from being a master of LaTeX myself, however I plan to introduce it
to a class of middle-to-high schoolers later this month, when I teach
Martian Math.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] generators in the field...

2018-06-09 Thread kirby urner
>
> In Pythonic Andragogy slides, a TextWriterTractor (subclass of Tractor)
> starts writing a user-provided phrase at whatever initially passed-in (x,y)
> position in the field.  Example:  Just Use It.
>
> A CropCircleTractor (another subclass) reads the Field as complex numbers
> and plants "@" where z = z * z + current(row, column) doesn't spiral out
> after n iterations.  Result:  A Mandelbrot Set.
>
> https://flic.kr/p/9AWnC2  (results of plowing)
>

​My apologies if the above link does not work for you.  The Flickr shortcut
feature seems to be more problematic that it used to be, don't know why.

https://www.flickr.com/photos/kirbyurner/5646223789/sizes/l

​... is another option.  Shows some ASCII art made using Tractors in a
Field pattern.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] generators in the field...

2018-06-09 Thread kirby urner
Wes asked (a couple posts back):  is a generator a type of callable?

Those copy/deepcopy links were helpful, I hope to any Python students
trekking through here. edu-sig is a great climb for those into learning
curves.

Most definitely a generator is a "callable" as, in my Python for Kids (not
a trademark [nTM]), a callable is simply "something with a mouth" where "a
mouth" is an open-closed paren, with or without arguments.

In a course or presentation, one might go into "emoticons" here, as
distinct from emoji, coming before emoji in the evolution e.g. :-D and :-(
were part of "ascii email" early on (SMTP etc.).

In this older emoticon language, :-() shows "()" as a "mouth" i.e. parens
are lips, and a callable is "that which may have a mouth" in this sense
(albeit a sideways one).

The rule "no keyword is a callable" is the same as saying, no keyword has a
mouth.  There's no True() or if() and print() is not a keyword (used to be,
in older Pythons).  print is a function, and as such is a callable.

Generator function:

>>> new_gen = pi()  # returns digits of pi [1]
>>> next(new_gen)
3
>>> next(new_gen)
1
>>> next(new_gen)
4
>>> next(new_gen)
1
>>> next(new_gen)
9
...

One of my favorite decorators comes from a David Beazely Youtube I watched
where he goes something like:

def nudge(f):
"nudger"
def started():
g = f()
g.send(None) # or next(g) -- goes to first yield and waits
return g
return started

What this does is take a generator object at define time and replace it
with a proxy wherein it has already been "nudged" to the first yield, and
is now waiting to be fed to next() or to have send() fire, which will at
this point, after nudging, have a corresponding yield queued up to receive
whatever.

As ya'll recall, a generator on birth has its execution pointer still at
the top, no steps taken, and the first next or send(None) takes it to the
first yield, where it may output, and then "waits" (actually suspends
execution and returns control to the caller thread).

next(gen) always means: take steps to the next yield, or: raise a
StopIteration if hitting return or falling off the end.

In other words, at birth, a generator is not ready for any substantive
obj.send(arg) because it's not at a yield yet.  nudge (above) takes care of
that for us, returning a proxy generator with "its pump already primed" so
to speak, g.send(None) having taken g to the first yield already.

In action:

@nudge
def get_mail():
"Get mail!"
pickup = "nothing yet..."
while True:
pickup = (yield "Thank you for sending me {}".format(pickup))
if pickup == "q":
break

gm = get_mail() # a generator function
try:
while True:
email = input("What to send? (q to quit): ")
output = gm.send(email)
print(output)
except StopIteration:
print("We appreciate your business")

RUNTIME:

What to send? (q to quit): birthday card
Thank you for sending me birthday card

What to send? (q to quit): postcard
Thank you for sending me postcard

What to send? (q to quit): q
We appreciate your business

Note: David Beazely is not in favor of having having a single yield both
output and take input, as above, regarding such a double-duty yield as too
confusing.  My code might count as demented in his book.

One of my favorite use of the generator-with-send ability patterns is what
I call Tractor in a Farm [nTM].

Farm(ville) is an n x m array of dots or other character, could be numbers,
and a Tractor is an iterator following some raster pattern, of row: each
column, next row: each column and so on.

When it finishes row 0 it jumps to the start of row 1, so not really a
tractor -- more like how people read these left-to-right languages (like
you're reading now).  If the field were a cylinder, with East and West
connecting, the tractor would go in a North to South spiral.

At the bottom right, a Tractor starts over at the top left (so a donut?).

Change in [row][column] (position) is what next() has the tractor do
(there's a __next__ method).

But then "fuel level" is dropping with each advance in some models, and
without the occasional "send" of more fuel, the tractor will come to a
grinding halt in the middle of a field somewhere (demented, but good for
learning purposes).

What's useful about this pattern is it's all "ASCII art" or "Unicode art"
at first, but yet gives the idea of "pixels" (row, column) and therefore
"pixel depth" (the bits needed to define a character), so the transition to
a discussion of binary files, say with R, G, B layers, is pretty easy.

The iterator : iterable relationship, between Tractor(s) : Field is pretty
intuitive also, owing to the extended metaphor.  The tractor is even
simpler than the turtle concept deriving from Logo, as the tractor has a
fixed and closed path.

Finally, said tractors have a "read" and "write" verbs, or "sense" and
"plant", meaning they're able to "write" to whatever cell (patch of Field)
they're in 

[Edu-sig] another perennial topic... callable functions versus types

2018-06-08 Thread kirby urner
I enjoyed our discussion of post-its versus buckets, or not versus:
 objects in memory take up space, and so are bucket-like, but look how many
labels (post-its) some of them have!

I find it useful to have memory take shape as something finite, even when
we're enjoying more of it on contemporary devices.  Python is biased
against making gratuitous copies, or against copying gratuitously, we maybe
could say.

Memory is respected.  L.sort() is "in place" whereas sorted(L) leaves L
untouched.  This "inplace" idea carries forward as a keyword argument
(named parameter) in many cases.

I confess, in my own courses, I could do more with deepcopy, explaining
what it is and how to do it.  I'll get on it.

When is it a copy, when a view? is a discussion in pandas as well.

Another topic:

Another pair of categories I like to tease apart are function versus type,
when it comes to what's a callable.

range() used to be a function that returned a list.  Now it returns an
instance of the range type, a sequence.  More like dict(), int() and so
on.  Not like hex().

enumerate() and zip() are likewise calls to classes, triggers to __init__s
(birth methods).  We're asking for instances.  We're calling types.

Functions return objects too, so one should not say the difference is
whether they return objects.  Both do.

The difference is instances of a type live on with the methods of that
type, whereas a function does not directly bequeath its methods to any
"children".

Functions are factories of other than instances of themselves, even if they
return other functions.

What nuances this view is that FunctionType is a type of object, so calling
a function is calling a type.

However, the way a function responds to being called is like an instance
does when its type has a __call__ method defined.

===

One of my favorite ways to connect classes and functions is to show how a
class might "eat" a function such that the function remains callable, and
yet the instances may also multiply, in which case the functions compose to
create other functions:

@Composable  # class
def F(x):
return x + 2

@Composable  # class
def G(x):
return 2 * x

H = F * F * F * G * G

(H is now a "pipeline" of F(F(F(G(G(x)  )

More on REPL.it:

https://repl.it/@kurner/Composing-Functions

(red X warning flag next to lambda expression is bogus, runs fine, Spyder
is smarter)

Kirby

PS:  this morning I saw Guido's talk at Stanford on type annotations, which
he recently tweeted about [1].  I definitely include mentioning to be on
the lookout for such syntax going forward, and not being thrown by it.  I
emphasize that standard core Python sees annotations more as a type of
documentation, with 3rd party hooks understanding them more as directives.

[1]
https://twitter.com/gvanrossum/status/1003792557652914177
(June 4)
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] names versus objects, reference counting etc. (was Code to Joy...)

2018-06-03 Thread kirby urner
Responding to the most recent by Wes...

Excellent & Comprehensive.  Thanks for bringing sys.refcount to the table.

I think newcomers sometimes grow in confidence when they get these peeks
into back stage behind-the-scenes stuff.

As long as we express it clearly, we're putting folks on a fast track to
becoming "insiders".
 ​

> # We usually don't ``del(variable)`` in Python because the garbage
> collector will free that memory anyway whenever it happens to run and the
> refcount is zero because the variable has fallen out of scope.
> #
>

A tiny point:

del variable

is slightly more correct than

del(variable)

following the rule that "no keyword is a callable".

You have it right in your dialog with the interpreter.

Remembering that rule saves people treating if and return as callables as
well, which I consider an "accent".

if(condition):
   return(object)

Still works.  You see this when students are coming from other languages.

Just the parens aren't doing anything.

>>> import keyword
>>> keyword.kwlist

A list of not-callable names.
​

> # In practice, we name global variables in ``ALL_CAPS`` (and may expect
> them to be constants). We wrap 'private' variable names with dunder
> (``__variable__``) so that other code can't modify those object attributes
> (due to 'name mangling').
>


​I believe best practice is to put the double-underlines only on the left
e.g.  hidden = __variable

The two underlines on the left side are sufficient to provoke name mangling.

The rule here is:  Python provides us with the special names ( __ribs__ );
we don't create them.

​

> Sometimes, we name variables with a single ``_underscore`` in order to
> avoid a 'variable name collision' with outer scopes (or to indicate, by
> convention, that a variable is a local variable)
> #
>


​Yes.  I tell people the _semi_private names are not guaranteed to stay the
same from version to version i.e. the coder is telling the code reader "use
this at your own risk, I'm not guaranteeing it'll still be there later".

I.e.  _semi_private names are not part of the official API, are
specifically excluded therefrom.

Often used for method names internal to classes.

The same goes for __super_private, only more so.

​

> # In practice, we try to avoid using globals because when or if we try to
> add threads (or port to C/C++), we're never quite sure whether one thread
> has modified that global; that's called a *race condition*. Some languages
> -- particularly functional languages like Haskell and Erlang -- only have
> mostly all immutable variables; which avoids race conditions (and the
> necessary variable locking that's slowing down Python GIL removal efforts).
>

​Yes, in practice best to have globals be immutable type objects, not a
place to store state.

I think of the django settings.py and other such config files as places to
store framework-wide globals.
​

> #
> # Is it a box or a bucket?
> # It's a smart pointer to an allocated section of RAM.
> #
>

​The allocated section of RAM is the box or bucket.

Names and Objects are distinct.

Names (pointers) go to the left of the assignment operator, Objects
(containers) to the right of same.
​

> # When do we get a new box and throw an old one away? Is there a name for
> the box and the thing in the bucket? Does the bucket change size when?
> #
>

​Bucket = Box = Object (on the heap).

Name = Post-it = Label = Tag

https://flic.kr/p/DQb8t6

Names must take up a little bit of memory too.  Very long names take up a
little more.
​

> # I think the box/bucket metaphor is confusing and limiting; but I've been
> doing this for a long time: it's a leaky abstraction.
> #
> # - https://en.wikipedia.org/wiki/Memory_leak
> # - https://en.wikipedia.org/wiki/Race_condition
> # - https://en.wikipedia.org/wiki/Smart_pointer
>
>
​Lets not forget weakref  -- worth bringing in right when we're talking
about garbage collection and reference counts.

https://docs.python.org/3/library/weakref.html
​
Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Code to Joy in The Economist (June/July 2018)

2018-06-03 Thread kirby urner
Jake VanderPlas gets into the "bucket" versus "pointer" discussion in his
Whirlwind Tour:

https://jakevdp.github.io/WhirlwindTourOfPython/03-semantics-variables.html

As long as your bucket is allowed to have multiple post-its (labels), and
as long as it's easy to unstick a post-it from one bucket and apply it to
another, there's no confusion.

The problem arises when one has only buckets with their individual names,
such as A and B, such that detaching the name (a post-it) from the bucket
can't happen.

How can changing the contents of bucket A change the contents of bucket B?
Answer:  they're the same bucket.  But if each bucket has a name carved
into it, as if in stone...

We see that mental picture in lots teaching materials, appropriate for
other languages more than for Python:

Example:

https://www.slideshare.net/PeterAndrews1/variables-13032998

(these slides don't suggest I can detach names from buckets and use them
for other buckets)

I would emphasize that Python buckets are essentially anonymous in the
sense that they have no permanent name assigned to them, and when no names
are assigned, they're eligible for garbage collection.

Getting clear on all this is not extraneous but essential as when we get to
pandas and start slicing in to larger data frames, we often get "views" not
"copies".  Python is just like that.

import pandas as pd
import numpy as np

data = pd.DataFrame(data = np.random.randint(9,size=9).reshape(3,3),
index = ['A','B','C'])

view = data.loc["A":"B"]  # slice (rows A,B), no copy made
print(data)
print()
view.loc['A'][0] = -1 # assign to slice, row A, column 0
print(data) # underlying DataFrame has changed

   0  1  2
A  3  8  5
B  6  4  1
C  7  4  4

   0  1  2
A -1  8  5
B  6  4  1
C  7  4  4

Kirby


PS:  I don't think it necessary to quote an entire thread one adding to it,
given the public archive contains the entire conversation.  I encourage
posters to trim, and keep only what they're directly responding to.
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Code to Joy in The Economist (June/July 2018)

2018-06-02 Thread kirby urner
>
>
>
> (a ratio of ratios, would show this way it next books in my era
>

​[sic]​  textbooks  e.g. dog : wolf :: cat : tiger  (opinions may vary)

Final remark: examples of my 'rear view mirror' Jupyter Notebooks
used during recent meet-up

(#10 of a 10x 4-hour on-line Python course):

https://github.com/4dsolutions/Python5/blob/master/PySummary1.ipynb
https://github.com/4dsolutions/Python5/blob/master/PySummary2.ipynb
https://github.com/4dsolutions/Python5/blob/master/PySummary3.ipynb


These try to pack in a lot of what we covered.

In retrospect, I gave the keyword 'nonlocal' short shrift and
need to address this more completely in future editions.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Code to Joy in The Economist (June/July 2018)

2018-06-02 Thread kirby urner
On Sat, Jun 2, 2018 at 1:13 PM, kirby urner  wrote:

>
>
>
> Name : Object :: Luggage Tags :: Suitcase
>

​Fixing this:

Names: Object :: Luggage Tags : Suitcase

(a ratio of ratios, would show this way it next books in my era, as in
"this is to that :: ("as") that is to this other" and so on).

I appreciate the Pycon 2018 account / perspective Naomi.  Glad to know
Andrew was attending in person and is reaping the benefits of joining a
subculture / community, not just learning a computer language

[ these go together, as most but not all, science fiction writers failed to
predict i.e. that computer languages create tribalism in a positive way ].

Tangential remarks:

* I just discovered Pyx this morning: http://pyx.sourceforge.net/

* I've made progress using RhinoScript (rs) a Python module compatible with
2.7 that runs inside a CAD system (proprietary, not unlike ESRI Arc* in
that regard).

* compiling PostGIS version of postgesql on old OSX Yosemite fails in the
homebrew recipe, after about 5 hours doing OK. More in blogs happy to yak
off-list.

Kirby






Kirby


Kirby
​

>
> One suitcase (object) may have many names (connects to garbage collection
> discussion).  However at any one moment, a name points to only one object
> (the same name in different modules, both running, still count as different
> names -- scope matters).
>
> So yeah, the object itself is a "container" but what it contains may be
> tags to other objects.
>
> Without this separation of "names" from "objects" there's an inevitable
> tendency to imagine copies, as how can we have two bowls or boxes with
> exactly the same content.
>
> We don't have a visual metaphor for "two suitcases containing exactly the
> same clothes at the same time".
>
> But we do understand "one suitcase having two or more luggage tags."
>
> Surely we have two copies, albeit clones of the same thing.  Not so in
> Python though.  Python is biased against making gratuitous copies of
> anything.  Keep is spare! (sparse if possible).  Don't clutter memory with
> excessive redundancy.
>
>
> Kirby
>
> **
> http://4dsolutions.net/presentations/pycon2013.pdf
>
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Python in 1843 Magazine (was ... Economist (June/July 2018))

2018-06-02 Thread kirby urner
​I stand corrected.  *1843 Magazine* is An Economist Group Publication,
same as The Economist.


COPYRIGHT © THE ECONOMIST NEWSPAPER LIMITED 2018
ALL RIGHTS RESERVED

AN ECONOMIST GROUP PUBLICATION
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Code to Joy in The Economist (June/July 2018)

2018-06-02 Thread kirby urner
One of my screen scraper friends (always reading) just forwarded this link:

https://www.1843magazine.com/features/code-to-joy

A highly literate middle aged writer tackles programming from zero and
winds up in Python after a pilgrimmage through Javascript, and uses the
Twitter API.  He meditates on what learning to code might mean to a fully
developed adult such as himself (connects to Andragogy **).

Nicholas Tollervey, sometime edu-sig poster and Micro:bit avatar, is very
much a hero in this story, living up to the ideal of a Pythonista as

(A) not religiously dogmatic (re "language wars") yet
(B) having enthusiasm for sharing Python (without too much proselytizing).

Bravo on a stellar performance!

Quincy Larson of freeCodeCamp fame is another champion of openness and
accessibility (and good advice).  I get his emails in my inbox with
gratitude, though I don't follow all the links (helpfully labeled with
estimated reading times, for my internal scheduler -- thanks for the
meta-data!).

In the interests of sparking some edu-sig type discussion (this could fork
to a new thread), the author Andrew Smith writes:

"Variables are best (if imperfectly) understood as the vessels within which
pieces of data are contained, ready to be worked on. Of many possible data
types, the most straightforward are numbers and strings, string being the
name given to text."

In my classes I readily acknowledge the "variable as container" metaphor is
apt, and agree that Python objects take up memory and so object ==
container (with id) is OK too.

However, the name --> object mapping of a namespace is better imagined as
"luggage tag -> suitcase" relationship. It's not like the Python name
itself is the container on the heap.

The object in memory is a possibly fat heavy suitcase, stuffed with stuff
(e.g. an HttpResponse).  However the name is more a label, like a luggage
tag on a suitcase (and this is the point).

Name : Object :: Luggage Tags :: Suitcase

One suitcase (object) may have many names (connects to garbage collection
discussion).  However at any one moment, a name points to only one object
(the same name in different modules, both running, still count as different
names -- scope matters).

So yeah, the object itself is a "container" but what it contains may be
tags to other objects.

Without this separation of "names" from "objects" there's an inevitable
tendency to imagine copies, as how can we have two bowls or boxes with
exactly the same content.

We don't have a visual metaphor for "two suitcases containing exactly the
same clothes at the same time".

But we do understand "one suitcase having two or more luggage tags."

Surely we have two copies, albeit clones of the same thing.  Not so in
Python though.  Python is biased against making gratuitous copies of
anything.  Keep is spare! (sparse if possible).  Don't clutter memory with
excessive redundancy.


Kirby

**
http://4dsolutions.net/presentations/pycon2013.pdf
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] contemporary Jupyter Notebooks for Python students (exhibit)

2018-05-29 Thread kirby urner
A couple links to Jupyter Notebooks I'll be going over tonight, with my
Python students.

The focus is data science however I'm a big believer in showcasing the
pandas ecosystem from the beginning.

I'll mostly be in Show & Tell mode, but then take excerpts, such as my
Galton Board bell curvy Pascal's Triangle thing, and bring it up in Spyder
for deeper analysis. [1]

https://github.com/4dsolutions/Python5/blob/master/PYT_DS_SAISOFT_MPL_01.ipynb

https://github.com/4dsolutions/Python5/blob/master/PYT_DS_SAISOFT_MPL_02.ipynb

The second one is especially focused on geospatial displays, prototypical
of what high schools tackle.

Kirby

[1]
https://github.com/4dsolutions/Python5/blob/master/STEM%20Mathematics.ipynb

(scroll down for Pascal's Triangle)
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Google Colab

2018-05-28 Thread kirby urner
On Mon, May 28, 2018 at 1:01 AM, Dominik George  wrote:


> Please do NOT use such tools in education.
>
> Cheers,
> Nik
>

​Good point Nik.

My only concrete plan to use Jupyter Notebooks in the classroom is during a
summer camp next month. My expectation is we'll install the Anaconda distro
either on OSX or Windows depending on whether Reed College wants Saturday
Academy to provide its own laptops. Theirs are Apple, and for all I know
already have Jupyter Notebooks installed.

Currently, I teach MIT Scratch to kids, which Coding with Kids (a company)
sees as a bridge to Python, which we also share, via Codesters.com, both
on-line platforms offering free accounts.

The head office creates the accounts and passwords and the kids learn to
log into them.  Many of them are quite young (not the Python students, more
like middle school).  We do not currently teach about Jupyter Notebooks.

My adult students do get a lot of about Jupyter Notebooks from me​. I
consider this technology rather integral to learning Python for workplace
use.

We use a Google Drive to share the files, but students do not need a Google
account to access the drive, only the link. Most my classes are BYOD so
it's up to each student to configure a local platform.  They might be using
Ubuntu.

You're right that requiring students to have Google accounts can be
problematic.  Like you say, as minors they're too young to navigate the
fine print.  Most oldsters don't carefully read the EULAs either (that's
Microsoft terminology).

However education is all about self teaching and many students freely
choose to avail of Google's services, starting with Gmail.  For this
reason, I don't worry about sharing news of this service on edu-sig,
leaving it to individuals to make their own choices.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Google Colab

2018-05-27 Thread kirby urner
Wes or someone may have linked to this already. Just tuned it in myself:

https://colab.research.google.com/notebooks/basic_features_overview.ipynb

That's Google's way of letting us use Jupyter Notebooks in the cloud and to
share them on Google Drive.

I see where students would benefit, not that this is the first or only
cloud-based environment.  Another great tool.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] CP4E meets Geospatial Data (DGGS)

2018-05-27 Thread kirby urner
I'm ramping up with Saturday Academy having met with their IT Chief
regarding getting Python distro Anaconda on the schools Windows laptops,
though at the moment we're thinking a Reed College Mac OSX classroom may be
our venue.  Next month is the target date.


That's where I
​​
taught Martian Math before, but sans any Jupyter Notebooks [0].


"Martian Math" unifies two threads I've been leaving posts about this month:


(A) getting into 3rd party functions around numpy, pandas and geopandas,
even pre-college, looks good on a "resume" (as in "in the summer of 2018 I
learned to use Jupyter Notebooks while studying geometric concepts using
Python").


(B) the set of concepts I've circled in my Digital Mathematics: Heuristics
for Teachers website at Wikieducator.


A "glue topic" is "HP4E" named in honor of "CP4E" the latter being in some
ways the raison d'être of this mailman listserv.[1]


Not many schools yet have access to DGGS systems (Discrete Global Grid
Systems) but we may anticipate many will in the near future.


Open source appears to be moving in this direction.


https://youtu.be/JWl4ZPrb5Ag  (hexapent)

https://www.slideshare.net/ClintonDow/dggs-python-geopython-2017 (a slide
deck)


Speaking of DGGS and HP4E, I got geopandas working today [2], though I
first made the mistake of thinking a simple:


conda install geopandas  (not the right way!)


was gonna work. On the contrary, you need something more like:


conda create -n geopandas python=3.6 geopandas -c condo-forge  (try this!)


i.e. let the conda-forge repo put all the dependences in a fresh new
environment.


Don’t over-install on the default Anaconda distro.  I see from exploring
Stackoverflow and so on that a lot of developers have made this mistake.


Kirby


[0] https://youtu.be/vk-cpknOz9E (10 minute Youtube on the genesis of
Martian Math)


[1]  https://www.python.org/doc/essays/cp4e/


[2]  http://mybizmo.blogspot.com/2018/05/geopandas.html
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Suggested metrics for measuring our success

2018-05-14 Thread kirby urner
On Mon, May 14, 2018 at 10:00 PM, Sebastian Silva  wrote:

> Sorry I missed pasting the link:
>
> https://educa.juegos/libro/#Jappy-TiddlyWiki
>
>
​Cool!

https://flic.kr/p/2772Gis

​Kirby

​
​​
>
>
> On 14/05/18 23:22, Sebastian Silva wrote:
> > For instance, here's an article with an embedded Jappy editor. The
> > included script is able to pull the code from the code sections of the
> > article in order to run it.
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Free Python teaching resources: Computer Science Teachers Association of Ireland

2018-05-13 Thread kirby urner
On Sun, May 13, 2018 at 1:26 PM, Stephen Murphy 
wrote:

> Hi Wes,
>
> Thanks for those! I look forward to exploring those paths!
>
> Best wishes,
>
> Stephen
>


​Wes has been a goldmine of useful links.

I encourage folks to mine the archives.

edu-sig is a gem among gems.

Kirby

​PS:  in the sense of Python signifying "access to treasure" (ala Vaults of
Parnassus):

https://youtu.be/MH49zLTeQsE
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] recent wheel spinning... (spatial geom)

2018-05-13 Thread kirby urner
On Sat, May 12, 2018 at 2:25 PM, kirby urner <kirby.ur...@gmail.com> wrote:



> https://github.com/4dsolutions/Python5/blob/master/Generating%20the%20FCC.
> ipynb
>
> Next challenge is to segment the dataframe vertically, into nucleus (1)
> plus successive layers (12, 42, 92...).
>
> Kirby
>
>

​Done!

#%%
# hierarchical row levels
arrays = [['layer0'] + ['layer1'] * 12 + ['layer2'] * 42,
  range(1 + 12 + 42)]

tuples = list(zip(*arrays))
rowindex = pd.MultiIndex.from_tuples(tuples, names=['Shell', 'Ball'])
#%%​


​Those weird %% thingys are I-Python / Spyder's way of letting run down a
script in discrete chunks.

To give a sense of the data:

Vtype   ivm xyz
Coordsa  b  c  d  x  y  z
Shell  Ball
layer0 0  0  0  0  0  0.000  0.000  0.000
layer1 1  0  1  1  2  0.000 -0.707 -0.707
   2  0  1  2  1 -0.707  0.000 -0.707
   3  0  2  1  1 -0.707 -0.707  0.000
   4  1  0  1  2  0.707  0.000 -0.707​

​
Sharing this JN out to Facebook on math teacher group:

https://www.facebook.com/groups/147158235484661/

Great for anyone into linear algebra at all.

Kirby
​
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What do folks think of creating a #python-k12 channel on freenode?

2018-05-13 Thread kirby urner
On Thu, May 10, 2018 at 3:06 PM, A Jorge Garcia via Edu-sig <
edu-sig@python.org> wrote:
>
> How about a Twitter hashtag?


Great idea.

What tag?

I do a lot of networking on Twitter.

Recent tweets:

https://twitter.com/thekirbster/status/991153490612269056

https://twitter.com/thekirbster/status/995728079677870081

I think my focus will be recruiting new people to this listserv, edu-sig.

I like the public archive and the long history we already have.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] recent wheel spinning... (spatial geom)

2018-05-12 Thread kirby urner
>
>
>
> [2]   C6XTY @ sa: this Thursday:
> https://flic.kr/p/HnGeut
>
> (sa: is where I've taught Martian Math before)
> http://www.4dsolutions.net/satacad/martianmath/toc.html
> http://wikieducator.org/Martian_Math
>
>

​In this post I'm merging two threads:

(i) introduce some of the high end 3rd party stuff early e.g. science stack
numpy and pandas

(ii) segue a geometry that requires some rethinking of familiar orthodoxies.

Example:


pd.options.display.float_format = '{:,.3f}'.format
data = pd.DataFrame(vectors, columns = index)
print(data)
Vtypeivm  xyz
Coords a b c d  x  y  z
0  0.000 1.000 1.000 2.000  0.000 -0.707 -0.707
1  1.000 0.000 1.000 2.000  0.707  0.000 -0.707
2  2.000 0.000 1.000 1.000  0.707  0.707  0.000
3  0.000 2.000 1.000 1.000 -0.707 -0.707  0.000
4  0.000 1.000 2.000 1.000 -0.707  0.000 -0.707
5  1.000 2.000 1.000 0.000 -0.707  0.000  0.707
6  1.000 1.000 2.000 0.000 -0.707  0.707  0.000
7  2.000 1.000 1.000 0.000  0.000  0.707  0.707
8  1.000 0.000 2.000 1.000  0.000  0.707 -0.707
9  1.000 2.000 0.000 1.000  0.000 -0.707  0.707
10 2.000 1.000 0.000 1.000  0.707  0.000  0.707
11 1.000 1.000 0.000 2.000  0.707 -0.707  0.000

​
Getting such multi-indexing requires such as:


arrays = [['ivm', 'ivm', 'ivm', 'ivm', 'xyz', 'xyz', 'xyz'],
  ['a', 'b', 'c', 'd', 'x', 'y', 'z',]]

tuples = list(zip(*arrays))
index = pd.MultiIndex.from_tuples(tuples, names=['Vtype', 'Coords'])

Call it business math if you like, micro-management of data tables via some
command line interface.

https://en.wikipedia.org/wiki/In_the_Beginning..._Was_the_Command_Line

That's using the multi-indexing phenomenon (object) the pandas dataframes
provide.

Above, I'm showing vectors in two notations, side by side, with a link to
their colorful depictions, in terms of ball packings, at this still
improving Jupyter Notebook:

https://github.com/4dsolutions/Python5/blob/master/Generating%20the%20FCC.ipynb

Next challenge is to segment the dataframe vertically, into nucleus (1)
plus successive layers (12, 42, 92...).

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Suggested metrics for measuring our success

2018-05-12 Thread kirby urner
Yeah, what's education without metrics for success.

On that theme, how about the edu-sig home page @ Python.org, what might we
do with it?

I wrote an initial version in the distant past, then Andre took over and
made it better.  The entire website got a new look.

However, more years have flown by and there's no mention of Jupyter
Notebooks, and some of the links e.g. pykata, are broken.

Why not mention codesters.com for example?  Lots of other interesting stuff.

I don't have the keys to that web page myself but we could encourage a
thread for whomever gets them or has them.

I find Jupyter Notebooks to be a really excellent tool for high school and
even middle school access to Python.

The mix of coding, and writing a paper, with pictures and links, is just
right.

Embedded graphs make it the perfect Algebra 2 environment.

Add Sympy and a little LaTeX and you've got calculus.

Kirby


On Sat, May 12, 2018 at 8:28 AM, Jeff Elkner  wrote:

> Dear Education Pythonistas,
>
> I'd like to suggest two useful metrics for measuring the effectiveness of
> our list:
> 1. Variety of posters.
> 2. Number of conversations.
>
> Our Community Code of Conduct commits us to conducting ourselves in a
> welcoming and respectful way, and what better measure of how well we are
> doing than the diversity of different folks who post on this list?
>
> If Edu-sig is about building and nurturing our python in education
> community, what better way to measure how well we are doing than by the
> number of posts that turn into conversational threads?
>
> I occasionally receive emails from teachers asking about good resources
> for teaching CS with Python.  This year I am going to try asking them to
> join this mailing list and to post their question on it, and commit to
> providing the best response I can here.
>
> Jeff Elkner
>
> Let's work together to create a just and sustainable world!
>
>
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] What do folks think of creating a #python-k12 channel on freenode?

2018-05-11 Thread kirby urner
>>  Would anyone else here have an interest in such a channel?

I'm game.

Wondering if irc has a good Android app front end these days.  Oh yeah,
tons.

Limechat is free client on Mac.

Lotta folks using #Slack these days which allows embedding pix, going back
to edit posts.

But maybe need free and open enuff, philosophically less apropos?

#Slack is free (as in beer) but not open (as in free).

edu-sig / mail-list format good for pondering out loud though.

I always encourage more public archiving of state of the art thinking.

I think of chat as more for real time quick back and forth, which is good,
but not for white papers and policy writing, or lengthy rants. :-D

Kirby



On Thu, May 10, 2018 at 2:15 PM, Jeff Elkner  wrote:

> Dear edu-sig friends,
>
> We had an interesting discussion at the Education Summit today at
> Pycon about ways to better engage folks between Pycons.
>
> As a public school teacher, I have a particular interest in python in
> k12 institutions, and in addition to posting more often on this list,
> I am considering setting up an irc channel on freenode (#python-k12 ?)
>
> Would anyone else here have an interest in such a channel?
>
> Jeff Elkner
>
> Let's work together to create a just and sustainable world!
>
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Using real world functions to teach arg passing

2018-04-23 Thread kirby urner
I'm becoming increasingly aware that the flood of new Python users we're
enjoying has everything to do with articles such as this one in Atlantic
Monthly last month:

https://www.theatlantic.com/science/archive/2018/04/the-
scientific-paper-is-obsolete/556676/

I've appended a couple quotes from it.

I enjoyed another perspective on the "Mathematica versus Open Source"
face-off  (Python's ecosystem in particular) in my joining what had been a
Mathematica-focused company (Netmath) that then morphed into a Python
teaching company (the O'Reilly School of Tech.).

I joined after the Netmath chapter, but the purchased company was still
working to make Mathematica a more popular front end by developing a
product named Hilbert.

https://www.cnet.com/news/oreilly-taking-mathematica-online/

Hilbert did the job it was supposed to, and we offered some calculus, but
that's not where the market turned out to be. People were flooding into
Python, still are.

These days I'm all about what the article talks about: Jupyter Notebooks
and the various tools it works with.

Here's my latest thinking:

When first introducing argument passing to functions, along with defining
function parameters, using * and ** in particular (as scatter-gatherers)
that's the right time to start using some of these fancy 3rd party packages
like matplotlib and numpy, for your examples.

Your average Python student is like a grad student in physics or
statistics.  They have lots of STEM skills and just want to get on with it
efficiently, without getting side-tracked into investing a huge number of
hours in a computer language (approximately the same user profile Guido
encountered at Stichting Mathematisch Centrum -- ABC users -- i.e. the
language attracts those for whom it was designed).

If you get to such as numpy.random.random and matplotlib.pyplot.hist right
away (with the appropriate abbreviations), that's like fresh air, oxygen,
what they've come for in the first place, so why delay?

Sure it's fine to show a couple functions like this for starters:

def F(*args, **kwargs):
 print(args, kwargs)

... but then visit the docs and start showing actual function signatures of
the Pyladies and such are *really* using.

Build a dict of arguments and pass it with **.

"""
Three ways to say the same thing
"""

import numpy as np
import matplotlib.pyplot as plt
from inspect import signature

# some data
x = np.arange(0,10)
y = np.random.randint(0, 5, size=10)

plt.subplot(311)
plt.plot(x, y, 'go--', linewidth=2, markersize=12)

plt.subplot(312)
plt.plot(x, y, color='green', marker='o', linestyle='dashed',
linewidth=2, markersize=12)

plt.subplot(313)
params = {'color':'green', 'marker':'o',
  'linestyle':'dashed', 'linewidth':2, 'markersize':12}

print(signature(plt.plot))
plt.plot(*(x,y), **params)

Side topic:  some Python instructors think "keyword arguments and
parameters" is a bit confusing given we also have what're called the
"Python keywords" (in keyword.kwlist -- except not async or await for some
reason, even in 3.6, I guess because local to a namespace?). They prefer
"named arguments".  However that suggests positional arguments are
"unnamed" which isn't quite right either. If there's no *args to scoop up
positionals first, dicts work to populate 'em, by name:

In [147]: def F(x, y, *, z):
 ...: print(x, y, z)

In [148]: kwargs = {'y':10, 'x':'A', 'z':100}
In [149]: F(**kwargs)
A 10 100


Even though we don't typically build dicts simply for the sole purpose of
passing named arguments in our matplotlib or numpy tutorials, I think we
should do that more in classes where core Python is still a focus.  In
other words, don't "save the best for last".

Start using the best right from the top, to teach Python basics.

Everyone can relate to a histogram or two, perhaps drawn at random from
some normal distribution.  Or plot real data why not?  Keep it topical in
some way.

[ The data don't have to be dismal either (so much of stats tries to be
"meaningful" in ways I consider less important than using a realistically
complicated API). ]

I'm working on moving in this direction for my courses in May.

In June, I'm hoping to teach high school and middle schoolers how to use
Jupyter Notebooks in the context of introducing what I call Martian Math.
If you've been on this listserv for awhile, you know it's a pet topic of
mine. We'll be using Anaconda on Windows.

Kirby

PS:  I won't be making it to Cleveland this year, but I'm vicariously a
participant in living close to where This is the Bus -- a
Pythonista-modified school bus ala Ken Kesey that will feature in one of
the Cleveland Pycon talks -- is starting from.  Here's its picture, with
more next to it if you click in Flickr:

https://flic.kr/p/JcUt3E


>From Atlantic Monthly:

Python became a de facto standard for scientific computing because
open-source developers like Pérez happened to build useful tools for it;
and open-source developers have flocked to Python because it 

Re: [Edu-sig] Simplest webapps

2018-04-03 Thread kirby urner
On Mon, Apr 2, 2018 at 4:16 PM, Carl Karsten  wrote:

​...
​

> http://www.web2py.com/init/default/download
> "After download, unzip it and click on web2py.exe (windows) or
> web2py.app (osx). To run from source, type: python2.7 web2py.py"   (I
> guess Linux users are good with "run from source")
>
>
​I see it also runs under Python 3.5/3.6

http://www.web2py.com/init/default/what

​Great.  Handsome website too!

I have a hard time recommending 2.7-based tools to any newcomers to Python,
echoing Guido:  https://youtu.be/GudJlbK4TY8

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Simplest webapps

2018-03-30 Thread kirby urner
Very interesting.  I note that free users are relegated to Python 2.7

Server modules can be Python 3.6 (outside the free version)

Client stuff compiles to JavaScript and is approximately 2.7

That's a bit confusing maybe.  I try to avoid 2.7 but that's not easy.

In my Coding with Kids work, we use Codesters.com to teach Python, which
depends on Skulpt.  Also 2.x ish.

Kirby



On Fri, Mar 30, 2018 at 11:49 AM, Jason Blum <jason.b...@gmail.com> wrote:

> http://anvil.works/ is a pretty interesting approach to Python web
> applications.
>
> On Fri, Mar 30, 2018 at 2:05 PM, kirby urner <kirby.ur...@gmail.com>
> wrote:
>
>>
>> Hi Aivar --
>>
>> I think it's a fine idea to write simple Python scripts that write HTML
>> files, which you may then pull up in the browser.
>>
>> There's no need to put a server behind static web pages.  So, for
>> example, I'll have my students write a page of bookmarks:
>>
>> # -*- coding: utf-8 -*-
>> """
>> Created on Wed Nov  4 18:02:30 2015
>>
>> @author: Kirby Urner
>> """
>>
>> # tuple of tuples
>> bookmarks = (
>> ("Anaconda.org", "http://anaconda.org;),
>> ("Python.org", "http://python.org;),
>> ("Python Docs", "https://docs.python.org/3/;),
>> ("Spaghetti Code", "http://c2.com/cgi/wiki?SpaghettiCode;),
>> ("Structured Programming", "http://c2.com/cgi/wiki?Struct
>> uredProgramming"),
>> ("Map of Languages", "http://archive.oreilly.com/pu
>> b/a/oreilly//news/languageposter_0504.html"),
>> ("XKCD", "http://xkcd.com;),
>> )
>>
>> page = '''\
>> 
>> {}
>> '''
>>
>> html = """\
>> 
>> 
>> Bookmarks for Python
>> 
>> 
>> Bookmarks
>> 
>> 
>> {}
>> 
>> 
>> 
>> """.lower()
>>
>> the_body = ""
>> for place, url in bookmarks:
>> the_body += "{}\n".format(url, place)
>>
>> webpage = open("links.html", "w")
>> print(page.format(html.format(the_body)), file=webpage)
>> webpage.close()
>>
>> All you need add to your example is using print() to save to a file, so
>> the browser has something to open.
>>
>> I would not call this a "web app" yet it's instructive in showing how
>> Python can write HTML files.
>>
>> Kirby
>>
>>
>>
>> On Wed, Mar 28, 2018 at 12:18 AM, Aivar Annamaa <aivar.anna...@ut.ee>
>> wrote:
>>
>>> Hi!
>>> Let's say my students are able to write programs like this:
>>>
>>> name = input("name")
>>>
>>> if name == "Pete":
>>> greeting = "Hi"
>>> else:
>>> greeting = "Hello!"
>>>
>>> print(f"""
>>> 
>>> 
>>> {greeting} {name}!
>>> 
>>> 
>>> """)
>>>
>>> I'd like to allow them start writing web-apps without introducing
>>> functions first (most web-frameworks require functions).
>>>
>>> It occurred to me that it's not hard to create a wrapper, which presents
>>> this code as a web-app (input would be patched to look up GET or POST
>>> parameters with given name).
>>>
>>> This approach would allow simple debugging of the code on local machine
>>> and no extra libraries are required in this phase.
>>>
>>> Any opinions on this? Has this been tried before?
>>>
>>> best regards,
>>> Aivar
>>>
>>> ___
>>> Edu-sig mailing list
>>> Edu-sig@python.org
>>> https://mail.python.org/mailman/listinfo/edu-sig
>>>
>>>
>>
>> ___
>> Edu-sig mailing list
>> Edu-sig@python.org
>> https://mail.python.org/mailman/listinfo/edu-sig
>>
>>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Simplest webapps

2018-03-30 Thread kirby urner
Hi Aivar --

I think it's a fine idea to write simple Python scripts that write HTML
files, which you may then pull up in the browser.

There's no need to put a server behind static web pages.  So, for example,
I'll have my students write a page of bookmarks:

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  4 18:02:30 2015

@author: Kirby Urner
"""

# tuple of tuples
bookmarks = (
("Anaconda.org", "http://anaconda.org;),
("Python.org", "http://python.org;),
("Python Docs", "https://docs.python.org/3/;),
("Spaghetti Code", "http://c2.com/cgi/wiki?SpaghettiCode;),
("Structured Programming", "http://c2.com/cgi/wiki?StructuredProgramming
"),
("Map of Languages", "
http://archive.oreilly.com/pub/a/oreilly//news/languageposter_0504.html;),
("XKCD", "http://xkcd.com;),
)

page = '''\

{}
'''

html = """\


Bookmarks for Python


Bookmarks


{}



""".lower()

the_body = ""
for place, url in bookmarks:
the_body += "{}\n".format(url, place)

webpage = open("links.html", "w")
print(page.format(html.format(the_body)), file=webpage)
webpage.close()

All you need add to your example is using print() to save to a file, so the
browser has something to open.

I would not call this a "web app" yet it's instructive in showing how
Python can write HTML files.

Kirby



On Wed, Mar 28, 2018 at 12:18 AM, Aivar Annamaa <aivar.anna...@ut.ee> wrote:

> Hi!
> Let's say my students are able to write programs like this:
>
> name = input("name")
>
> if name == "Pete":
> greeting = "Hi"
> else:
> greeting = "Hello!"
>
> print(f"""
> 
> 
> {greeting} {name}!
> 
> 
> """)
>
> I'd like to allow them start writing web-apps without introducing
> functions first (most web-frameworks require functions).
>
> It occurred to me that it's not hard to create a wrapper, which presents
> this code as a web-app (input would be patched to look up GET or POST
> parameters with given name).
>
> This approach would allow simple debugging of the code on local machine
> and no extra libraries are required in this phase.
>
> Any opinions on this? Has this been tried before?
>
> best regards,
> Aivar
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] still admiring J

2018-03-23 Thread kirby urner
On Fri, Mar 23, 2018 at 1:33 AM, Wes Turner  wrote:

>
> xarray.Dataset is n-dimensional
> https://xarray.pydata.org/en/stable/
>
> From a tweet a few days ago https://twitter.com/westurner/
> status/973058715149578240 :
>
>
​Excellent pointers!

I anticipate a steady stream of new math teachers (sort of like I was some
decades back, teaching high school level in Jersey City, first job outta
college),  and getting to where they're hungry to include more coding, and
need appropriately mathy topics.

Lots out there already, a steadily growing stash since the early days, of
Logo and OLPC (One Laptop per Child), SugarLabs...  The Learning to Code
movement (code.org etc.) is but the latest in a series of chapters.

BTW, one of my code school mentors just showed me this one:
http://www.codebymath.com/index.php/welcome/lesson_menu

My own contributions to this genre go back to what I called the "Numeracy
Series".  That's closer to when I first came across Python. I'd already
played with "quadrays" in Visual Foxpro.[0]

http://4dsolutions.net/ocn/numeracy0.html  (that's part 1 of 4, early 2000s)

I was into mixing Python with POV-Ray, the free ray-tracer, to get simple
geometric figures.

These days mathy high school level topics might include...

-

*1*  Crypto: a gateway to group theory.  Since my day, we've added more to
the "fun reading" shelf, such as with Cryptonomicon (Stephenson, historical
science fiction) and The Theory that Would Not Die (i.e. Bayesianism) by
McGrayne.  As clear from the cover (https://flic.kr/p/22z1vAy) she's
covering a lot of the same territory: Bletchley Park, Alan Turing, enigma
machines.  You've got prime numbers, RSA, Elliptic Curves and hashlib SHA
stuff.  Introduce blockchain.  A great way to access recent history.

*2* Geometry: and in my case a genre of "mental geometry".  My topic is the
somewhat off-beat solid geometry of the geodesic dome dude (another movie
coming up [2]), and my modality is often Python.  One of the slides shows a
Tetrahedron class with our formula for its volume, a public sandbox at
REPL.IT. https://repl.it/@kurner/tetravolumes

I don't remember if I've already shared this link ( https://goo.gl/zoVYF1 )
to my slide deck (Google Slides) for a recent talk at Systems Science
building, Portland State [1].

That's probably still too off beat for most, whereas Fractals (dynamical
systems, strange attractors, Wolfram automata), if counted as "geometry"
(certainly visual) already have a strong following and both connect back to
deeper math.  I've done work around those topics too and attest to Python's
applicability.

*3*  Data Science: which is where the nD-array ("xray", "tensor") and
Linear Algebra come in, and Calculus (which they're learning anyway).  When
not connect Calc to Stats with a thicker pipeline right from the start?
So what if the Gaussian Distribution doesn't have a closed form integral or
whatever (https://goo.gl/9XyzN5 )?  Not an issue.  We just wanna make sense
of the curves in some lessons, and both the CDF (the integral) and
derivative of the PDF (normal curve) are worth talking about visually, and
coding in Python.[3]

-

In sum:  if you're a math teacher chomping at the bit for something fresh,
and not already over-exploited by the test-maker economy (you still have a
free hand), then we have riches in:

Crypto (web browser TLS, eCommerce, Supermarket Math [4]);

Geometry, including off-beat whole-number volumed polyhedrons from New
England Transcendentalist literature (v 2.0);

Machine Learning / Data Science. All accessible to high schoolers.

Kirby

[0]  Quadrays are a weird coordinate system featuring a "caltrop" of basis
rays to tetrahedron corner points (1,0,0,0) (0,1,0,0) (0,0,1,0) (0,0,0,1)
from origin (0,0,0,0) -- but there's nothing "4D" in the sense of
non-visualizable hyper-dimensional, just ordinary space mapping, 1-to-1
with XYZ if you stick to the unique canonical representation.
http://mathforum.org/library/view/6236.html

[1]  http://worldgame.blogspot.com/2018/03/systems-science.html

[2]  https://youtu.be/oyLWPWydvyo

[3]  one of my Jupyter Notebooks about the bell curve:
https://github.com/4dsolutions/Python5/blob/master/BellCurve.ipynb

​
​[4]  http://wikieducator.org/Supermarket_Math
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] still admiring J

2018-03-22 Thread kirby urner
Greetings edu-siggers!

Way back in the archives you'll find me extolling a language known as J, by
Kenneth Iverson, his son Eric, and Roger Hui. I never met any of these guys
in person, but knew of Iverson through APL, which I discovered at
Princeton, and fell in love with.  Iverson helped me squish some typos in
my Jiving with J.[1]

What I admire about J, as about R and Python via Numpy, is the inclusion of
an n-Dimensional Block (array, addressable memory with multiple axes), as a
language native, a core star.  J reads like a right-to-left pipeline with
an nD Block going through it.  I guess we'd need to call that a Functional
Programming language right?

As the former high school math teacher (long ago -- though I'm still in the
schools, as recently as today in fact, as an after school Python
instructor), I still chafe at the fact that we don't dive in with these
tools at that age level, except in rare cases, and instead insist on
students buying all those TIs year after year.  But that's me the broken
record.

For those schools that break out, charter or public (nevermind, how they
talk in the US makes n sense), there's a world of wonderful technology
to explore, while learning the math that matters.  y = mx + b.  Turn m over
for w, and b is for bias.[2]

Kirby

[1]  http://www.4dsolutions.net/ocn/Jlang.html

[2]
https://www.google.com/search?q=mcdonalds+upside+down+w=off=lnms=isch
(recent meme)
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] generic objects (including lambdas) as dict keys?: not usually a problem

2018-03-20 Thread kirby urner
I just discovered for myself what many must already know: lambda
expressions may serve as dict keys (I knew values).  That means they may
partake of the mutability of some functions, in having mutable default
parameter values.


In [122]: d = {lambda x=[10]: print(x.append(11), x) : 3}

In [123]: list(d.keys())[0]()

None [10, 11]


In [124]: list(d.keys())[0]()

None [10, 11, 11]


In [125]: list(d.keys())[0]()

None [10, 11, 11, 11]


In [126]: list(d.keys())[0]()

None [10, 11, 11, 11, 11]

That's not going to corrupt the dict though.  In general, callable objects
may serve as keys, with lambda expressions a special case. So what if the
object points to mutable content.


In [127]: class Callable:
 ...: def __init__(self):
 ...: self.the_list = []
 ...: def __call__(self, *args):
 ...: self.the_list.extend(args)


In [128]: obj = Callable()

In [129]: the_dict = {obj : 3}

In [130]: list(the_dict.keys())[0]("troll farm")

In [131]: obj.__dict__

Out[131]: {'the_list': ['troll farm']}

On the other hand, if you define __eq__ vis-a-vis something mutable, then
the dict-maker will have 2nd thoughts about the viability of your
enterprise.

So nothing that earth-shaking.  It's the Python we all know.

Just thought I'd say hi.  More soon.

Kirby Urner
Portland, OR
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] probability and statistics demo for kids

2018-02-24 Thread kirby urner
On Sat, Feb 24, 2018 at 5:21 PM, Wes Turner  wrote:

>
>
> +1. "Python Data Science Handbook" (by Jake VanderPlas) is available in
> print and as free Jupyter notebooks:
> https://github.com/jakevdp/PythonDataScienceHandbook
>
> It covers IPython, NumPy, Pandas, Matplotlib, and Scikit-Learn.
>
>
>

​Yes!  Open on my desk in front of me.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] probability and statistics demo for kids

2018-02-24 Thread kirby urner
​In terms of Machine Learning more generally, I want to give special
recognition to Jake VanderPlas, an astronomer who dives deep into
scikit-learn in some multi-hour Youtube-shared tutorials.

Example:
https://youtu.be/L7R4HUQ-eQ0

His excellent keynote at Pycon2017:
https://youtu.be/ZyjCqQEUa8o

Jake does a super-excellent job of showing off the internal consistency of
the scikit-learn API, where you can basically use the same code while just
swapping in one classifier or regressor for another.

He also speaks the jargon pretty flawlessly, to my ears at least, in terms
of what's a feature (label) and what's an observation etc., going into both
supervised and unsupervised learning scenarios (scikit-learn handles both).

Bravo Jake.

Allen Downey has great complementary tutorials which go deeper into the
statistical thinking behind these ML models.  ThinkBayes is fantastic.

It's tempting to just mindlessly throw models at data looking for a best
fit, and maybe that's all some underpaid cube farmer has time for, but
VanderPlas, along with Downey, wisely counsels against that.

Stats more than most is a minefield of pitfalls, such as overfitting. If
your aim is authentic research, then mindless model-slinging will quickly
come up against its own limitations.  That's the message I keep getting
from experts in the field.

Kirby

PS:  thanks to Steve Holden, I got to visit the astronomy world up close,
the form of the Hubble Space Telescope instrumentation team, eager for
Python knowledge.  These were already programmers, experts with IDL, but
IDL is not the hard currency Python is, in the wider job market.  For many
reasons, astronomers can't put all their eggs in one basket.  The Python
ecosystem has been a godsend.




​
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] probability and statistics demo for kids

2018-02-23 Thread kirby urner
I'm a big fan of Galton Boards:

https://youtu.be/3m4bxse2JEQ  (lots more on Youtube)

Python + Dice idea = Simple Code

http://www.pythonforbeginners.com/code-snippets-source-code/game-rolling-the-dice/

I'd introduce the idea that 1 die = Uniform Probability but 2+ dice =
Binomial distribution (because there are more ways to roll some numbers,
e.g. 7 than others, e.g. 12).

A Python generator for Pascal's Triangle (= Binomial Distribution):

def pascal():
row = [1]
while True:
yield row
row = [i+j for i,j in zip([0]+row, row+[0])]


gen = pascal()

for _ in range(10):
print(next(gen))

[1]
[1, 1]
[1, 2, 1]
[1, 3, 3, 1]
[1, 4, 6, 4, 1]
[1, 5, 10, 10, 5, 1]
[1, 6, 15, 20, 15, 6, 1]
[1, 7, 21, 35, 35, 21, 7, 1]
[1, 8, 28, 56, 70, 56, 28, 8, 1]
[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]

Kirby


On Tue, Feb 20, 2018 at 6:12 PM, Perry Grossman  wrote:

> I am thinking of doing a simplified interactive presentation on
> probability and Bayesian statistics for my kids' elementary school.
> I think it would probably be best for 6-8th graders, but there might be
> ways to do this for younger students.
> I'd like to run some Python code to show probability distributions and
> statistics.
>
> I am thinking of simplified examples from these works:
>
> Maybe the dice problem, or the cookie problem here:
> Allen Downey - Bayesian statistics made simple - PyCon 2016
> 
>
> A friend also suggested doing an analysis of how many cards (e.g. pokemon)
> that one might need to buy to colleft the whole set.
>
> Any suggestions on how to make this manageable approachable for kids?
>
> Perry
>
> PS:  right now I'm going through Allen Downey's tutorial on Bayesian stats
>> using the above mentioned tools, from Pycon 2016:
>> https://youtu.be/TpgiFIGXcT4
>> I attended this conference, but didn't manage to make this tutorial.
>>
>> [1]  I've shared this before, still relevant:
>> https://medium.com/@kirbyurner/is-code-school-the-new-high-s
>> chool-30a8874170b
>>
>> Also this blog post:
>> http://mybizmo.blogspot.com/2018/02/magic-squares.html
>> -- next part --
>> An HTML attachment was scrubbed...
>> URL: > 19/d9e2f965/attachment-0001.html>
>>
>> --
>>
>> Subject: Digest Footer
>>
>> ___
>> Edu-sig mailing list
>> Edu-sig@python.org
>> https://mail.python.org/mailman/listinfo/edu-sig
>>
>>
>> --
>>
>> End of Edu-sig Digest, Vol 174, Issue 1
>> ***
>>
>
> ___
> Edu-sig mailing list
> Edu-sig@python.org
> https://mail.python.org/mailman/listinfo/edu-sig
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] if I taught high school calculus today...

2018-02-19 Thread kirby urner
I was a high school calculus teacher (also algebra, geometry, trig) first
job outta university, stuck with it for two years.

Fast forward to almost age 60, and I'm teaching coding to middle schoolers,
thinking it's all still math. [1]

Shouldn't take a "computer scientist" to cover this stuff... Algorithms are
algorithms after all.

Were I to teach calculus today, in light of what I now know, I'd focus on
probability density functions right when we get to integration, as "area
under the probability curve" is precisely how we figure out  chances of
something happening.

We would use Jupyter Notebooks with SciPy, all free & open source.

As I recall, our calc curriculum never did much to bridge to statistics,
but in SciPy / NumPy, every continuous probability distribution function
(PDF) comes with a cumulative distribution function (CDF) that's defined
exactly as a definite integral between A and B, and giving the probability
some x in distribution X falls between A and B.

Forming a bridge twixt calculus and data science would be another strategy
for getting scientific calculators to share the road, with more relevant
free tools (always an ulterior motive for me).  I don't think a TI is able
to do definite integration over a standard normal curve.

Actually, I see I'm wrong:
http://cfcc.edu/faculty/cmoore/TINormal.htm

Oh well, back to the drawing board.  I still think a strong tie-in twixt
calc and data science makes a lot of sense at the high school level. With
or without Jupyter Notebooks.

Kirby

PS:  right now I'm going through Allen Downey's tutorial on Bayesian stats
using the above mentioned tools, from Pycon 2016:
https://youtu.be/TpgiFIGXcT4
I attended this conference, but didn't manage to make this tutorial.

[1]  I've shared this before, still relevant:
https://medium.com/@kirbyurner/is-code-school-the-new-high-school-30a8874170b

Also this blog post:
http://mybizmo.blogspot.com/2018/02/magic-squares.html
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] the "best way" to teach Python

2017-12-27 Thread kirby urner
https://medium.com/@kirbyurner/whats-the-best-way-to-teach-python-675d4bfbdebd

Recent essay on Medium.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] Excel losing out to open source?

2017-12-17 Thread kirby urner
I know in my own Python classes I talk about the power of a pandas
dataframe as like having a spreadsheet and a database object combined, in a
container you get to program around, in Python.  What in Office is like
that?

There's an shift away from spreadsheets as the cornerstone of data analysis
perhaps?

The JP Bader link goes to further discussion.  Also check Chipy archives.

Kirby


Culling from Chipy (open archive):

-- Forwarded message --
From: Jeremy McMillan 
Date: Thu, Dec 14, 2017 at 7:06 PM
Subject: Re: [Chicago] Excel team considering Python as scripting language:
asking for feedback
To: The Chicago Python Users Group 


This looks like Microsoft realizing they are losing to Jupyter Notebook and
Pandas + Matpotlib.

On Thu, Dec 14, 2017 at 4:38 PM, JP Bader  wrote:

>  http://hn.premii.com/#/comments/15927132
>
> ___
> Chicago mailing list
> chic...@python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Lost reference to an online Scratch-like Python environment

2017-12-16 Thread kirby urner
Yes, Codesters is used by a company I sometimes work for called Coding with
Kids to teach Python "game development".

The core Python is 2.7, not 3.x.

If you search Public project with user name Kirby_cwk you should fine some
of mine (some of which are remixes of others', including students).

Let me know if you have questions about this platform and I'll seek to
answer from personal experience.

Kirby

(on the road, in Atlanta)

On Sat, Dec 16, 2017 at 6:59 AM, Aivar Annamaa  wrote:

> Found it finally! :)
>
> It's www.codesters.com
>
> Check it out: https://www.codesters.com/curriculum/intro-to-codesters/
> Building+your+First+Program/1/
>
> best regards,
> Aivar
>
>
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] thumbs up Socratia for Python teaching videos on Youtube

2017-12-04 Thread kirby urner
>From email (with attached invoice) to one of my clients (WorkingIT.com):


"""

I'm still liking Socratia, here's a new one on text files:

https://youtu.be/4mX0uPQFLDU  (I left a positive comment)

Good on using keyword 'with' when opening files, also on using
print(content, file = f) as an smart alternative. Bravo.

Happy New Year!

"""

Happy New Year edu-sig.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] discrete math track (high school) + a sieve

2017-11-16 Thread kirby urner
We've maybe seen this sieve before on edu-sig but I don't remember for
sure, and just came across it following links from Guido's blog.  So pithy!

# -*- coding: utf-8 -*-
"""
Created on Thu Nov 16 13:23:51 2017

Copied from:
http://www.mypy-lang.org/examples.html

"""

import itertools


def iter_primes():
 # An iterator of all numbers between 2 and
 # +infinity
 numbers = itertools.count(2)

 # Generate primes forever
 while True:
 # Get the first number from the iterator
 # (always a prime)
 prime = next(numbers)
 yield prime

 # This code iteratively builds up a chain
 # of filters...
 numbers = filter(prime.__rmod__, numbers)

for p in iter_primes():
if p > 1000:
break
print(p)

---

Also, anyone interested in debates regarding the future of high school math
might be interested in math-teach, likely to be frozen and/or disappeared
come first of next year.  Lots of politics (I'm not a listowner nor on
staff, have limited insight, see 2nd link below):

http://mathforum.org/kb/message.jspa?messageID=10283328

https://www.nctm.org/News-and-Calendar/Messages-from-the-President/Archive/Matt-Larson/NCTM-and-The-Math-Forum/


Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] when and why should kids learn Python?

2017-10-29 Thread kirby urner
>
> My big disappointment with Python was that graphics was not integrated
> more smoothly into the package.  Engineering involves a lot of plotting,
> and that should happen without extra effort.  The integration with C could
> also be improved, for those applications where speed is important.
>
>


Yes, I agree with your points, about the 2nd language being more
different.  Probably if #1 is Python, then #2 should be Lisp family as you
say, and/or strongly typed.

Regarding Python not natively including anything graphical in the Standard
Library or core, that's a barrier for younger students coming from an MIT
Scratch background, also strong on acoustics.  You may have seen Codesters
already.  Here's one I coded just last night as a part of an ongoing
discussion on math-teach (CS and math are becoming "as one" in the early
grades):

https://www.codesters.com/preview/11a6566e8105408489662f851bb21c7e/

You can actually run the code by clicking the green arrow button.  Notice
how the namespace is enhanced with Sprites and what not.  The goal is to
provide a graphical bridge to lexical programming,. I work for a company
that indeed uses this with kids.  I'm in some school or other every weekday
but Monday for about an hour after school -- so yeah, still extracurricular.

Codesters is Python 2.7 under the hood, not 3.x, which I consider a
weakness, but not a show stopper.  This is an "in between" platform.  We're
on our way to a more Jupyter Notebook + IDE like environment, and or
designing simple websites.

Speaking of websites, I'm into making examples that don't even use HTML
i.e. the HTTP requests are all for JSON data and the like.  Just to
separate the idea of "website" from the usual stereotype, of something we'd
want to "browse".

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] when and why should kids learn Python?

2017-10-28 Thread kirby urner
This Codepen is dual purpose in that the company I work for (one of them)
teaches with it, so I can say I'm promoting / recruiting for one of our
other (not Python) classes.

https://codepen.io/pdx4d/full/RjwrvG/

Ironically though, I'm actually coming to the conclusion that the "game
card" is over-played, by which I mean, we take kids' love of computer games
and suggest their hearts' desire is just a heart beat away.

But that's not so:  knowing how to code well enough to make games of real
interest (to them), takes time.  Lots of other tasks are more realistic:
making art, slide shows, ads, stories... along with rather simple game-like
activities.

But you've gotta focus on a lot of syntax and semantics first.  We need to
be up front about the need for concentration and practice.  Programming is
"hard fun". You don't learn Python in just a few hours, especially not if
it's a first lexical (not block-based) language.

The tiny games and game fragments that are within range, *may* be enough to
galvanize an ongoing interest in coding, but in a minority of cases.

Instead there's a sense of betrayal, of bait and switch, as "game
development" is oversold.  Simple animations would be fine if that's what
we offered.  Storyboarding and cartooning with Python -- makes sense.  But
the games they play incessantly, day in and day out, are often multi-user,
plus they're slick and well thought-out.

I'm more of the school of thought that if Learning to Code is to become a
mature aspect of the everyday curriculum, it'll need to merge in a lot of
math topics.  Bootstrap is already a big step in this direction.  I see
many signs that this merger is well underway.

In sum, I'm for using Python when there's related age-appropriate math we
might code around, such as the Sieve of Eratosthenes or prime factoring.
Functions, plotting, geometry... all good.

I'm against using Python as a "game development platform" with kids who are
too young to understand that their favorite computer games are not good
examples of what they'll be able to code any time soon.

My belief is CS has for so long has been an after school "computer club"
activity, that it still feels a need to pander, sell itself.  Math, on the
other hand, is a required non-elective subject between you and a high
school degree.

Now that coding has emerged as more of a priority in our culture, thanks to
many factors including industry pressure, it's starting to count towards
math credit in some cases, and maybe becoming a tad less obsequious in
recruiting?

The curriculum at Stuyvesant High School in New York City seems
appropriately serious, not all that game-oriented.  They're more Racket /
Scheme based than Python, and were that way prior to Bootstrap and/or
CS4ALL.

They do have some Python content though, judging solely from their website.

I followed their link, under resources, to http://codingbat.com/python
which I'm liking, though it's small.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] strategies for teaching Python

2017-10-02 Thread kirby urner
Given I'm spending 3-4 days a week with 5th & 6th graders, teaching them
Python, I'm looking for ways to sync with what Common Core says they should
be learning math-wise.

They general strategy here is to look for topics already in the curriculum
and develop coding skills around those topics.

Turns out that prime versus composite is important at that age, and the
classic algorithm used to teach that is the Sieve of Eratosthenes.  Most
coders have written at least one of those.

Since we're transitioning from block-based MIT Scratch with not much
keyboarding, to full-fledged lexical Python, I'm thinking to assess
facility with keyboarding (typing) by having them hand-enter a Sieve, and
running it to check for any syntax errors.

While we're still doing natural and whole numbers it makes sense to look at
other number series as well, ones we can explore using very simple Python.

Triangular and square numbers, then polyhedral number sequences, such as
successive shells around a nucleus. 1, 12, 42, 92...

http://oeis.org/A005901  (note link to my website under links)
https://github.com/4dsolutions/Python5/blob/master/STEM%20Mathematics.ipynb

Pascal's Triangle is an important hub for studying number sequences.  It
even embeds the Fibonacci Numbers.

These are the kinds of ideas I've been circling for some years.
http://4dsolutions.net/ocn/numeracy0.html

What's new is I'm getting more opportunities to test them in real world
classrooms. Coding with Kids is keeping me busy.

With my adult students, I'm looking at what I call the "Five Dimensions of
Python" wherein they expand their awareness of the language, from keywords
(dimension 0) to 3rd party ecosystem (dimension 4).

http://mybizmo.blogspot.com/2017/09/five-dimensions-of-python.html
(links to another Jupyter Notebook)

I've finally figured out that Codesters (codesters.com) is about Python
2.7, not Python 3.x.  I've been confused on that score.

Given cryptography is playing a more important role in everyday eCommerce,
it makes sense to beef up some of the Number and Group Theory aspects of
K-12.

I've been arguing on math-teach that right when we introduce primes versus
composites, we should likewise introduce Fermat's primality test.

http://mathforum.org/kb/message.jspa?messageID=10241002
http://mathforum.org/kb/thread.jspa?threadID=2883906

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] the SageMath saga: at the front lines in open source

2017-09-24 Thread kirby urner
I'm finally tuning in the saga of SageMath, with William Stein at the
center:

https://youtu.be/6eIoYMB_0Xc

The cited Youtube isn't the most recent of his Youtube presentations, but
provides a fascinating glimpse into the economic forces swirling around
open source in this next iteration / generation.

SageMath is GPL but without a company behind it, a business structure, what
will become of it?

Fast forward and said company exists, along with a grant from the EU.  Then
what?

On the Continuum Analytics side:  Jupyter Notebooks, likewise super-worthy
and deserving of committed developers who don't feel pressured to move on.
Mostly foundation funded.

One might think colleges and universities would see it in their common
interest to develop a liberal commons around such open source toolery.
What better way to attract top notch faculty?

One might also see a company like Google using the "half time" model and
paying employees, in some cases already versed in SageMath internals from
grad school, to code in support of these projects from which we all benefit.

That's a way of earning Good Will, in older economics texts an actual line
item the board members paid attention to.  It's a way of branding.

As Stein sees it, universities systematically undervalue mathematicians who
contribute to the commons in the form of software.

Taking a page from Jared Diamond ('How Civilizations Fail'), this is how we
shoot ourselves in the foot, by clinging to habits and stereotypes.  Or do
we break through to a next level?

Kirby

PS:  I consider SageMath part of the Python ecosystem so no worries
discussing it here (we have already).
https://en.wikipedia.org/wiki/SageMath
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] some new open source Python writing (Jupyter Notebooks)

2017-09-04 Thread kirby urner
>
> Maybe a bit OT:
>
>
OT:  "off topic" or "over the top"?  :-D

I've wondered whether we could/should instead start mathematics education
> with bits as entropy (information theory first)?:
>
>

That's an interesting suggestion.  When everything seems impenetrable /
indecipherable, we're in a high entropy state.

Like when you first get off the airplane in some alien culture and so much
of what goes on seems an utter mystery.

We're more like newborns.

Then as we "learn the ropes" and start to "figure it out" there's a sense
of Entropy decreasing.  It all makes more sense.

To a point.  :-D

Is the self-education process itself a struggle against our own mental
entropy?

- base 2: 00, 01, 10, 11 (on our hands (2**?))
> - counting
> - ASCII (0-127)
>   - how do we know the number represents an integer or a character? ...
> Encoding, Types
>   - The number zero is actually # (code point): ___
> - Unicode
> - class SpecialString(str)
>
>

http://4dsolutions.net/ocn/mainoutline.html



> - Binary and then floating point arithmetic
>   - unary, binary operators
> - import operators: sorted(dir(operators))
>   - left and right shift
>   - multiplication as repeated addition
>   - long division
> - floating point (error, BigFloat)
> - symbolic mathematics
>   - MathJax, LaTeX (how to even type this?)
>

I really like how I can put LaTeX between dollar signs in a Jupyter
Notebook and use it inline.

  - CAS: SymPy, latex2sympy
>
> - Entropy
>   - Independence of observations
>   - Maximum Information
>
>
Enlightenment!


...
>
> class Shape
> class Quadrilateral
> class Rectangle
> class Square
> class Triangle
> class RightTriangle
> def perimiter
> def area
> def vertexes
>
> def scale
> def rotate
>
> class PlatonicSolid
>
>
I started on a Polyhedrons notebook.  This is where I've invested a lot of
time over the years.

Bob and Wayne on math-teach say my use of Quadray Coordinates is not math.
Some kind of hocus pocus.

I'm the only one in the world who seems to think they have a place, if only
to stimulate our thinking about coordinate systems more generally.


...
>
> Are there computer science & mathematics curricula like this (that start
> with entropy)?
>
>
In the sense that we all start out ignorant of what these curricula aim to
signal, I think we all begin in a bath of noise.

Thanks as always for intriguing input.

I'm on a physics teacher list where they like to argue about Entropy and
how best to teach about it.

They're talking thermodynamics more than information theory, but that's all
the more reason to look for these unifying concepts.

Perhaps Hell is pure nonsense, separated from Heaven by the thinnest of
veils, like a decrypting key.

Like the less redundancy in a channel, the purer the signal, the closer it
comes to appearing random, if we're locked out of its meaning.

Right?

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] some new open source Python writing (Jupyter Notebooks)

2017-09-04 Thread kirby urner
PS:

my recent exercises in teaching math with Python, ala Peter Farrell, is
sparking some heated debate on math-teach.

http://mathforum.org/kb/thread.jspa?threadID=2876811  (especially in recent
days, early September 2017)

Bob Hansen is trashing this writing as some of the worst pedagogy he's ever
seen.

I'm trying to incorporate some of his feedback in my latest revisions.

Our debates are reminiscent of some we've had here on this list in years
gone by.

I've also been chronicling my progress in this related thread:

http://mathforum.org/kb/thread.jspa?threadID=2877392

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] some new open source Python writing (Jupyter Notebooks)

2017-09-03 Thread kirby urner
On Sat, Sep 2, 2017 at 8:42 PM, Charles Cossé  wrote:

> Hi Kirby,
> Thanks for sharing that.  Why do you call the GitHub repo "Python5"?
> -Charles
>
>
Greetings Charles.

Back when I was working for O'Reilly School of Tech, since closed, we
taught Python courses 1-4.  There was some talk of adding another level, as
we hadn't touched this or that topic (e.g. asyncio, descriptors, using
yield to send in...).

I created a "Python5" repo to dink around with stuff we might add.

Maybe in a decade or so, Python itself will catch up with the 5.x series.
:-D

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] some new open source Python writing (Jupyter Notebooks)

2017-09-02 Thread kirby urner
Sorry:

https://github.com/4dsolutions/Python5/blob/master/Introduction.ipynb

the previous one got away.

I confess to recycling some of my old materials, updating as I go.

What's new is the state of the art has continued to improve, thanks to the
hard work of many contributors.

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] some new open source Python writing (Jupyter Notebooks)

2017-09-02 Thread kirby urner

___
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig


<    1   2   3   4   5   6   7   8   9   10   >