Environments for Teaching Python in Middle and High School

I’ve been using python as the primary programming language for all of my classes, from middle to high school. However, with a variety of different machines and operating systems–macs, PC’s, OSX, Windows, ChromeOS–it has been bit of a pain getting everyone up and running and on the same page. It has been especially problematic because I like to use NumPy and, especially, the VPython module because of its nice, easy 3d visualizations.

I’ve tried Anaconda, which works great on some machines but not so much on others. One student with a Mac had to restart the kernel every time he ran a program with vpython, while others had trouble getting it to work properly at all. I do like the way it allows you to put everything into a single Jupyter Notebook, which works nicely for teaching-length programming assignments, but becomes cumbersome for longer projects. Joel Grus goes into detail about why he does not like Notebooks for teaching; much of which I agree with. I do like the Spyder IDE a lot, but I’ve run into some computers that have problems with it (constant crashes).

So, I’ve been using Glowscript a lot with the lower grades. It’s online, so you only need a browser, and its made for vpython, so you can do a lot of the numerical work with it. However, because it’s online you can’t, understandably, get it to write output files to your computer–you have to copy and paste from its output. I’m also not sure how to import user-created modules, which further limits its utility for higher-level classes.

I’ve recently run into repl.it, and I’m having a student try it out in my Numerical Methods class. It looks quite promising as it seems to be able to manage files well and we’ve tried some basic numerical programs using numpy and matplotlib. However, I’ve not got it running vPython yet (although it’s come close).

(repl.it update): One of our other teachers has been trying repl.it with the middle school class and really likes it.

I’ve also recently discovered MakeCode. I’m looking into it for the lower grades, down to 6th grade or even earlier, because it lets you write programs for Minecraft, which is very popular with a remarkably broad age group. It lets you work in blocks, python, or JavaScript. From my poking around, the first couple of things it teaches you to do in Minecraft are write statements (to generate a chicken) and the loops (to generate a lot of chickens). I’ve asked one of my 9th grade, Minecraft players to investigate, so I should have some results to report soon.

At the moment, for my most advanced class, we’re taking a whatever-works approach. We’re learning about finite differences and using matplotlib to graph the output. I have one student, mentioned above, using repl.it, and another one using Jupyter Notebook on a Mac. A different Mac user is invoking IDLE from the command line because they prefer the IDLE IDE, but couldn’t get numpy to install properly with the python 3.9 version they’d installed earlier–the command-line IDLE actually goes to their Anaconda installation. I have one student, on a Windows machine, for whom everything just works and are using their regular IDLE installation. We spent the entire class period getting everyone up and running with something, but at least now everyone has at least one environment they can use. I’m curious to see what the kids who have multiple options are going to go with.

3d Printable Microscopes

A few interesting, low-cost but potentially lab-grade, microscopes that would be great Makerspace projects for students.

OpenFlexure: Out of the University of Bath, this has a Raspberry Pi at the core that can control the stage, focus, and sensor (using the RPi camera module). Since it’s modular the cost varies with the image quality you’re aiming for, but it looks like you can achieve even high resolution results relatively cheaply. They have great detail on their website, including their own version of Raspbian to install on the Pi, so this looks like an good starter project.

UC2: I really like the look of this building block, LEGO-style, system. It seems extremely flexible and there are some interesting projects that go beyond your standard microscope. There are a lot of designs you can go with, including an Arduino or using a Raspberry Pi and camera, but they claim to get good results just with smartphones. This is a big, sprawling project, which suggests a slightly steeper learning curve.

Hat tip to Maggie Eisenberger for introducing me to these.

Playing with Electron Configurations

I upgraded the table part of the Electron Configuration Interactive I used in the app I made for Practicing Writing out Electron Configurations. It’s now more interactive and embeddable.

Click on the green cell (in the 3d subshell) to start adding electrons. Clicking on the previous cell will remove electrons.

The full documentation is here.

No Such Thing as Dark Matter

We’ve not been able to detect dark matter yet. Natalie Wolchover explains summarizes theories that could explain the way the universe works without having dark matter.

Key to it is the Modified Newtonian Dynamics (MOND) equation to explain why the stars at the outer edges of galaxies are moving faster than Newton’s force law predicts they should be.

Velocities of stars further away from the center of the galactic disk (larger R) have a higher velocity (V) than predicted by Newtonian physics. Dark matter has been used to explain this discrepancy, but tweaking the physics equations could do so as well. Image from Wikipedia.

Newton’s Second Law, finds that the Force (F) acting on an object is equal its mass (m) multiplied by its acceleration (a).

 F = m \cdot a

The MOND equation adjusts this by adding in another multiplication factor (μ)

 F = \mu \cdot m \cdot a

μ is just really close to 1 under “normal” everyday conditions, but gets bigger when accelerations are really, really small. Based on the evidence so far an equation for μ may be:

 \mu = \frac{a}{a_0} \frac{1}{\sqrt{1+\left(\frac{a}{a_0}\right)^2}}

where, a₀ is a really, really small acceleration.

Factoring this μ factor into the equation for the force due to gravity ( F_g ) changes it from:

 F_g = G \frac{ m_1 \cdot m_2}{r^2}

into:

 F_g = G \frac{(m_1 \cdot m_2)}{r^2} + \frac{\sqrt{G \cdot \m_1 \cdot m_2 \cdot a_0}}{r}

The key point is that in the first term, which is our standard version, the denominator is the radius squared (r^2) while the second term has a plain radius denominator (r).

This means as the distance between two objects gets larger, the first term decreases much faster and the second term becomes more important.

As a result, the gravitational pull between, say a star at the edge of a galaxy and the center of the galaxy, is not as small as the standard gravitational equation would predict it would be, and the stars a the edge of galaxies move faster than they would be predicted to be without the additional term.

References:

What is Dark Matter?

Adam Hadhazy, in Discover Magazine, summarizes the top candidates to explain dark matter and the experiments in progress to find them. These include, WIMPs (Weakly Interacting Massive Particles, Axions, Sterile Neutrinos, and SIMPs (Strongly Interacting Massive Particles.

Distortions in the shapes of galaxies caused by gravitational lensing. While gravitational lensing is caused by anything with gravity (this means normal matter as well) the lensing effect of dark matter is a key form of evidence for its presence. Image of the galaxy cluster Abell 2218 via Wikimedia Commons.

via Brian Resnick on Vox, who provides some very interesting historical context on the discovery of dark matter.

Electron Configuration Practice

A quick electron configuration practice webpage that lets you enter the symbol for an element and see if you can write out the electron configuration in both the full and noble gas forms.

Screen capture from the electron configuration webpage. Sulfur (S) is entered, and then the long form and noble gas form of the configurations can be entered and checked. In this case, there is an error in one part of the noble gas form.

The table at the bottom is a guide to filling the electron shells and orbitals. You can click any of the blue squares to change the number of electrons in the orbital.

Update

An improved version of the lower, table part is here.