Derivations Blog

Derivations

A place for deriving stuff. We take requests.

Previous in Blog: Disappointing ITER Delayed   Next in Blog: Quantum Physics and Chaos Theory Linked
Close
Close
Close
6 comments
Rate Comments: Nested

How to Use Python to Teach Physics

Posted July 15, 2016 7:43 AM by Bayes

I've been teaching myself Python for a while now and I really enjoy it and the things I can do with it. I found this article below interesting...

How to Use Python to Teach Physics

I RECENTLY FACILITATED a workshop for high school physics teachers in South Africa (two workshops actually—one in Johannesburg and one in Cape Town). The goal of the workshop was to introduce teachers to using python in physics. Since this was my first python-physics workshop, I feel I should share the details and some of the things I learned.

The Workshop Content

This was a four hour workshop so I had plenty of time (or so I thought) to let the teachers actually work on some python code. I started off with an introduction and short lecture on the basic idea of numerical calculations. After that, I would start with some example code (maybe complete or maybe incomplete) and then give the teachers time to work on some “homework” questions about that code.

You can find all my workshop notes (with links to code) in this Google doc. Yes, I probably should have used something other than a Google doc, but more on that later. But let me go over the basic outline.

  • Start with an object moving at a constant velocity and in one dimension. Go over the code and then give the participants an opportunity to change the code to answer some homework questions. Note: I decided to start off with very simple code. The results are printed out and there are no graphs and no 3D elements.
  • An object moving in 1D with a constant acceleration. This is essentially the same as the program above but with a non-zero acceleration.
  • Introduction to graphs. First, I show how to add a graph to the same constant acceleration problem and then I give the teachers a problem with two moving objects and they use a graph to find when these objects meet.
  • Mass on a vertical spring. This is a short mini-lecture in which I show both how to model the force due to a stretched spring and then how to make a python model of a mass oscillating on a vertical spring. I show what the output should look like and then give the participants code with some parts missing. After they get the program running, there are some questions to suggest things they could change.
  • Vectors and vector operations. This is just a demonstration of how VPython handles vectors. I have a sample code, but I don’t give them any questions to work on. Instead we just move to the next thing.
  • Introduction to 3D objects. I show the VPython objects: sphere, box, arrow. After that I show a simple example of a ball tossed in the air (straight up) with 3D visualizations. There is no homework for the participants, this is just a demo.
  • Projectile motion. The teachers are given the program of the ball tossed in the air (from the previous example) and then they need to make it a program with a ball tossed at angle.
  • I have more programs to go over, but in both workshops we were running out of time. I showed a demonstration of projectile motion with air resistance and orbital motion.

Again, all of these starter programs are in the resource document. That document also contains a link to the presentation I used in the workshop as well as other useful links.

The article continues here

Reply

Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru

Join Date: Jun 2009
Location: South of Minot North Dakota
Posts: 8376
Good Answers: 775
#1

Re: How to Use Python to Teach Physics

07/15/2016 3:06 PM

Ugh. Who comes up with the names for these things?

Reply
2
Guru

Join Date: Apr 2010
Location: About 4000 miles from the center of the earth (+/-100 mi)
Posts: 9912
Good Answers: 1141
#2
In reply to #1

Re: How to Use Python to Teach Physics

07/15/2016 9:23 PM

Since you asked...

"History[edit]

Guido van Rossum, the creator of Python Main article: History of Python

Python was conceived in the late 1980s,[31] and its implementation began in December 1989[32] byGuido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to the ABC language (itself inspired by SETL)[33]capable of exception handling and interfacing with the operating system Amoeba.[8] Van Rossum is Python's principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community,benevolent dictator for life (BDFL).

About the origin of Python, Van Rossum wrote in 1996:[34]

Over six years ago, in December 1989, I was looking for a "hobby" programming project that would keep me occupied during the week around Christmas. My office ... would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus)."

https://en.wikipedia.org/wiki/Python_(programming_language)

Reply Good Answer (Score 2)
Guru

Join Date: Jun 2009
Location: South of Minot North Dakota
Posts: 8376
Good Answers: 775
#3
In reply to #2

Re: How to Use Python to Teach Physics

07/15/2016 10:43 PM

Well since it's Monty Python based in origin I will let it slide.

Personally following that theme if I was feeling a bit irreverent when naming it I would have called it, "And now for something completely different."

Reply
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#4

Re: How to Use Python to Teach Physics

07/16/2016 7:28 AM

Many thanks, I will read all your documentation with great interest.

I am sure many others will be very interested too.

A project that I am very interested in for the last 12 months or so is programmed in Python as well.....

__________________
"What others say about you reveals more about them, than it does you." Anon.
Reply
Guru

Join Date: Apr 2010
Location: About 4000 miles from the center of the earth (+/-100 mi)
Posts: 9912
Good Answers: 1141
#5

Re: How to Use Python to Teach Physics

07/17/2016 8:52 PM

Never used Python. I'm kind of partial to Octave which is very close to MatLAB. It's a high enough level language that you can model physical processes without having to fuss with issues like data storage.

(I've found knowing too many languages leads to confusion. Most are so similar that the differences tend to trip you up, so I stick to one if possible.)

I totally agree that an engineer to contemplate and a computer to do the grunt work is the ideal symbiotic relationship. You can learn a lot by changing a parameter to see what happens!

Reply Score 1 for Good Answer
The Engineer
Engineering Fields - Engineering Physics - Physics... United States - Member - NY Popular Science - Genetics - Organic Chemistry... Popular Science - Cosmology - New Member Ingeniería en Español - Nuevo Miembro - New Member

Join Date: Feb 2005
Location: Albany, New York
Posts: 5060
Good Answers: 129
#6
In reply to #5

Re: How to Use Python to Teach Physics

07/18/2016 7:23 AM

Languages definitely are very similar and I confuse them with each other all the time. The worst is SQL because I worked with PostgreSQL for a while and now when I write T-SQL queries I include things like "limit 10" without thinking and then it takes a second for me to figure out why it didn't run.

Reply
Reply to Blog Entry 6 comments

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

Andy Germany (1); Bayes (1); Rixter (2); tcmtech (2)

Previous in Blog: Disappointing ITER Delayed   Next in Blog: Quantum Physics and Chaos Theory Linked

Advertisement