Programming Continued

I’ve been thinking some more about programming in the classroom. I tweeted Fraser Speirs and asked him why Ruby over Python:

I’m realizing that this is the only type of response you can give when asked “why one language over another?” Ultimately, it doesn’t really matter which language you learn, and at the end of the day, the preference and comfort of the instructor is what matters most, at least in the environment we’re both trying to succeed in.

It was Fraser’s recent article that really started giving me some good ideas. A few people on the Python edu-sig list have recommended iPython Notebooks, but I like the idea of setting up a server somewhere and running it straight and simple for everyone.

Fraser does mention Coda, which I’ve just tried out and I think this is the direction I want to go, even if just for myself right now.1 It’s easy enough to run a text editor and a terminal as separate applications, but why clutter your desktop when an application like Coda has already put together these elements into one app? Coda does Python and Ruby syntax highlighting, and the Terminal window in the app connects to the localhost no problem. Plus, once you’re using Coda for Python or Ruby development, you can start to use it for web development as well by learning about the preview and CSS editor windows. It’s an IDE that’s not really an IDE. Plus, it’s lightweight and has an iPad version (not sure if that can use a local terminal though).

The iPad is great, but I agree with Fraser that you’ll probably want to use a keyboard. The Verge recently wrote a review on the best iPad keyboards, and they pretty much say the same thing about typing on the iPad:

No matter which keyboard you choose, typing for extended periods on an iPad is a pain. Why? For starters, the iPad is meant to be touched with your fingers, and as much command you might have over “next line,” “next word,” and “next paragraph” keyboard shortcuts, you don’t quite realize how often you move your cursor onscreen until you type for a while on an iPad. This means you’ll be touching the screen quite a bit as you type, a distracting and not always precise procedure.

As I mentioned in my previous post, I want to go straight ahead with Python. I will be attending PyCon Canada and I hope I’ll run into some fellow educators.

Meanwhile, I may start looking at Ruby. This article was pretty honest and clear about the differences, but Python still appeals to me, for some of the reasons the author admits. This article about Ruby in education is pretty basic, but makes an interesting argument. I think I could make as equally a convincing argument with Python, but it’s worth exploring anyway.

One last thing… Codecademy has about 4 units up in Python and it’s worth checking out. There are lots of ways to learn programming in interactive ways, as well as great books like Learn Python the Hard Way. Hopefully my students will be able to find one way or another to get hooked.


  1. I’m still using version 1, not sure if I want to upgrade yet. 

Teaching Programming

I’m working on developing a programming workflow so that I can begin teaching programming to students. I’ve studied a lot of programming myself, and while I’ve never developed an ‘app’, I feel pretty confident in my ability to solve problems, especially those dealing with simple math operations, string manipulation, and basic logic.

When I learned programming it was always at the command line. We opened up pico or emacs, edited our code, saved, quit out of pico, compiled, and then ran. It was a simple workflow, and beyond including the standard libraries (in C/C++), there wasn’t much more to focus on than the actual program itself.

Fast forward a few years, and there I am with XCode installed on my MacBook, trying to follow along in an Integrated Development Environment. In XCode and Interface Builder, you can still work on your code (of course), but you also have to build window elements, and buttons, and there’s app delegates, and all sorts of different things to get confused by. Things get even more confusing when you realize that Apple is updated XCode almost constantly, and so not only is the language framework changing, but the development environment changes along with it. Apple updates things incessantly, constantly, and if you’re not right on top of that stuff, it can be very hard to follow along.

Sure, other languages and compilers and environments get updated. Python is in version 3 dot something now, but many people are still using 2 dot something. There are IDEs available with Python and there’s any number of modules and builds of Python. I don’t know exactly, but I’m sure this is the case with most languages and development platforms.

But, there’s no denying that at the command line, everything is simpler. If you’re developing simpler programs, then that’s probably the best thing to stick to. I eventually want to be able to whip up an iPad app in a weekend, but for demonstrating simple programming concepts to students, a simpler environment is going to be better each time.

I’ve decided upon Python as my direction for integrating programming into the math curriculum. Lots of people are using Python, and with languages, it’s wisest to go where there’s lots of support and documentation. Ruby is an option as well, but Python just seems more integrated to me.

So, in developing this workflow I’ve been experimenting with a bunch of different options. I was initially using TextWrangler and its own build window, but then I started needing the Terminal. I tried Coda, and a plug-in that I found that lets you build python right in the app. I tried doing it on the server where I host my websites, but they didn’t have very good support around python. I’ve tried Pythonista on the iPad, and Sublime Text 2 and its built in interpreter, as well as its terminal plug-in SublimeREPL.

There’s more traditional IDEs, like Eclipse, and NetBeans, and JetBrains. Of course, Python offers their own IDLE, but I found that to be fairly limited.

One of the things that has made this search slightly more difficult is my thought that I should figure out a way to have my students using PyLab. The truth of the matter is, we’re not really doing intensive stuff, it’s just that I want to have access to the various mathematics functions in those libraries. Plus, with matplotlib, I want them to be able to graph. Essentially, I’d like to replace the TI-83 altogether and have them using Python/PyLab instead.

I think it could work really well because Python runs live as well as through scripts. The live python could act as an in-the-moment calculator. You see the >>> prompt and you type in 100.4*6 and it spits out an answer, no programming knowledge necessary. Meanwhile, slowly, and awesomely we could start getting the computer to perform repeated operations for us, using programming. I want my students to walk out of the class knowing a new skill that can actually be used later for other things (Django anyone?). The TI-83 is a dead-end for students who see it as a tool only to be used in a math classroom, and even then they don’t know half of the features available.

Here’s the problem. Imagine, day one of class. “Class, I need everyone to come to the next class with PyLab installed on your machine.” Look, I’m pretty savvy with this stuff and I found it very tough to figure out how to install scipy, numpy, etc. You have to compile things on the command line, and it’s not easy.

It’s so difficult in fact that I wasn’t ever able to do it. If someone showed me how to do it, I could understand it, but even finding good tutorials is tough, and trust me, I looked. So, what’s the alternative? I found a few: The Enthought Python Distribution, SAGE, and the SciPy superpack. I found the EPD pretty easy to install, and everything you need is there. I haven’t played around with SAGE or the superpack yet.

Perhaps I could have my students install the EPD, and we’d all be happy. There’s one problem: not everyone has a computer, or wants to bring one to class everyday. Some students have iPads, and there should be a way to let them participate as well. Unfortunately, numpy/scipy/matplotlib isn’t yet available on the iPad (as far as I know). This makes me want to figure out a way to do this without using the scientific libraries.

There’s one more alternative that I recently read about. Fraser Speirs is attempting to do something similar, and what he’s done is set up a Linux server on the Amazon cloud services and have the students essentially SSH in. Cool. I would need to spend some time myself to get that all set up, and hopefully the server would support a full installation of PyLab, and I’m not sure if I could run the plotting software through that. Hmm. It may work with a little work, but if I want to get this started soon, I’m looking for the easiest solution first.

Right now, that’s going ahead without the scientific stuff and just using a plain vanilla Python. And it means going back to basics. I like Sublime Text 2, but students could find the text editor that works for them, BBEdit, TextWrangler, something on Windows. We’ll edit our code in the editor, and we’ll run it at the command line, just like how I learned. No IDEs, no fancy applications, just code and command line. For those on the iPad, Pythonista is the best option (it’s really nice).

I want to get more complex eventually, both for myself and my students. But, that might be a few years down the road. The first attempt has to be the simplest possible setup, so that any student can set it up and feel comfortable working with it from day one.

Number Theory Class 25 May 1

Previous: Encryption with Addition

Now: Encryption with Multiplication, hints of beyond

We are going to use a little trick from our past to help us calculate multiplicative inverses.

If we have time, we will see a nice table that “covers” exponential cryptography.

//Classwork:

Page Problems
349 1,2,3,5
397 1,2

Next:

  • Read
    • Encryption using Modular Multiplication, 8.5
    • Exponentiation Ciphers with a Prime Modulus, 9.4
    • Study for Final

Stats Class 25 May 1

Previous: Wrap up of Hypothesis Testing

Now: Correlation and Regression

There is a calculation to go along with correlation, but since we are time-constrained, we’ll use our calculators to figure out a value for r, which is known as Pearson’s correlation coefficient.

Once we have a value for r, we want to compare it to a critical value just as we did with hypothesis testing. The critical value chosen depends on the sample size and \(\alpha\), which could be 0.05 or 0.01.

Lastly, once you have decided that there is a correlation, and that r is significant, then one might want to generate an equation for the line of best fit. It’s pretty easy to generate the equation for the line of best fit once you have r using the formulas below.

The book uses different letters than you are probably used to for a linear equation. Instead of \(y=mx+b\), it’s written \(\hat{y}=a+bx\) To keep it simple we will use the letters we know.

\[m=r(\frac{S_y}{S_x})\]
\[b=\bar{y}-m\bar{x}\]

//Classwork:

Page Problems
134 20
145 Verify the r value provided in 7-10 is correct, then calculate m, and b. Also, Do part f for each problem.

Next:

  • Be Prepared
    • Review on Thursday May 3
    • Final on Thursday May 10, 8-10am

QR Class 24 April 26

Previous: Exponential Models and Vampires

Now: Special Topics: Golden Ratio and the Euclidean Algorithm

  1. Understanding the Fibonacci Series
  2. Seeing how that turns into the golden ratio
  3. Artistic Application Worksheet
  4. Bjorkland Algorithm for Musical Rhythm

//Classwork:

  • Lots of worksheets.
Page Problems
601 17

Next:

  • Read
    • Skim all of Chapter 11 and see if anything piques your interest

Number Theory Class 24 April 26

Previous: Check-Digits

Now: Elementary Cryptography

Encryption, like check-digit schemes goes up in complexity giving more security.

Addition is the easiest code to crack Then, multiplication Then, exponential…prime modulus Then, exponential…composite modulus…The hardest code to crack

Basically all cryptography is is taking a string of numbers and shifting it in some way (add, multiply, power), and reducing it in some modular system. The modular reduction makes it that much harder to see a pattern.

Decrypting can be done by reversing what was done to encrypt it, or better, just inverse what was done. That’s why we want to understand additive and multiplicative inverses.

//Classwork:

Page Problems
343 1,4,5,6
349 1,2,3,5

Next:

  • Read
    • Encryption using Modular Multiplication, 8.5

QR Class 23 April 24

Previous: Beginning Exponential Modeling

Now: Exponential Modeling

Just like in linear modeling, we had to learn to go between graphs, tables, and equations, we need to do the same thing with exponential models.

So far, we have learned how to plug in a growth rate and a starting value into a template to create an exponential model. But now, what if we encounter a graph, or a table with two points, how can we generate an equation from that?

//Classwork:

Supplement!

Next:

  • Read
    • Exponential Modeling, 9C