Tag Archives: Python

Programming FTW

trophyThis is a cross-post from my personal blog, Constant Safari.

“Victory is mine! I drink from the keg of glory. Bring me the finest muffins and bagels in all the land.”
(Josh Lyman/Aaron Sorkin)

It was a simple request. An administrator wanted to analyze all the assessments teachers had entered into the assessment calendar over the year. He wanted to look for trends, get some statistics, etc. His assistant wanted to look at the submission dates and see when people were posting things.

No problem. Our system exports calendar data. Click, click, click. Here you go, sir.

<crickets>

Calendar programs export calendar files. ical files. (.ics, to be exact.) They’re intended to be read by other calendars. Not spreadsheets.

This is what an appointment looks like in an ical file:

event

This is not pretty stuff. But it is analyzable. I showed the admin where the data was that he wanted. He’s a savvy guy and not afraid of getting his hands dirty with back-end computing, but the look he gave me was grim. There were thousands of events in this calendar. And he was going to do this every year.

No problem. I said. I’ll clean it up with Python.

About an hour (most of it QA & me looking commands up in a reference book) and 34 lines of code later, I was able to offer him the same data. Only this time it looked like this:

cleanedup

And, I told him, we could now do the same data cleanup any time he wanted to look at information in a matter of seconds.

Programming is not just for software developers!

Please note: I am not a developer. I do not consider myself a “real” programmer. I dabble. I teach high school students to program. I know my way around a program. I’ve coded various things but nothing terribly serious.

The program I wrote is not highly technical coding.  One of my high school students could have done it. (I showed it to them the next day. They all got it. One student suggested an tweak.)

ANYBODY can learn to do this. And it can be very practical. Al Sweigart has written a new book about how non-developers can write simple Python programs to automate boring real-life tasks. (Read about it here.)

EVERYBODY should know how to do this. (At least some of it.) Computers are here and they’re not going away. Learning to program them in this age is like learning to read was in centuries past. Christan Genco makes the case (far better than I could) in this TEDx talk:

If you’re ready to try, start out with Dr. Chuck (Charles Severance)’s Programming for Everybody course. He’s a great teacher and will get you going with Python.

Thank you. I’m going off now to slay a dragon.

Programming FTW

trophy“Victory is mine! I drink from the keg of glory. Bring me the finest muffins and bagels in all the land.”
(Josh Lyman/Aaron Sorkin)

It was a simple request. An administrator wanted to analyze all the assessments teachers had entered into the assessment calendar over the year. He wanted to look for trends, get some statistics, etc. His assistant wanted to look at the submission dates and see when people were posting things.

No problem. Our system exports calendar data. Click, click, click. Here you go, sir.

<crickets>

Calendar programs export calendar files. ical files. (.ics, to be exact.) They’re intended to be read by other calendars. Not spreadsheets.

This is what an appointment looks like in an ical file:

event

This is not pretty stuff. But it is analyzable. I showed the admin where the data was that he wanted. He’s a savvy guy and not afraid of getting his hands dirty with back-end computing, but the look he gave me was grim. There were thousands of events in this calendar. And he was going to do this every year.

No problem. I said. I’ll clean it up with Python.

About an hour (most of it QA & me looking commands up in a reference book) and 34 lines of code later, I was able to offer him the same data. Only this time it looked like this:

cleanedup

And, I told him, we could now do the same data cleanup any time he wanted to look at information in a matter of seconds.

Programming is not just for software developers!

Please note: I am not a developer. I do not consider myself a “real” programmer. I dabble. I teach high school students to program. I know my way around a program. I’ve coded various things but nothing terribly serious.

The program I wrote is not highly technical coding.  One of my high school students could have done it. (I showed it to them the next day. They all got it. One student suggested an tweak.)

ANYBODY can learn to do this. And it can be very practical. Al Sweigart has written a new book about how non-developers can write simple Python programs to automate boring real-life tasks. (Read about it here.)

EVERYBODY should know how to do this. (At least some of it.) Computers are here and they’re not going away. Learning to program them in this age is like learning to read was in centuries past. Christan Genco makes the case (far better than I could) in this TEDx talk:

If you’re ready to try, start out with Dr. Chuck (Charles Severance)’s Programming for Everybody course. He’s a great teacher and will get you going with Python.

Thank you. I’m going off now to slay a dragon.

A MOOC more Open than Massive

I’ve just completed a MOOC on programming with Python called “Python for Informatics.” It was created and taught by Dr. Chuck (Charles Severance), on a platform that he built.

This was the second course I’d taken with Dr. Chuck: I’d also taken his Coursera class, “Internet History, Technology, and Security.” That was a very interesting and engaging course, and I found it very worthwhile. It was definitely a massively open course! Here are his statistics: ” Over 49,000 students registered for the free class, over 16,000 attended the first week’s lecture and over 4900 students earned a certificate at the end of the 10-week course.” (I was one of the 10% who completed it. 🙂 )

When I heard Dr. Chuck was creating his own platform, I was intrigued. I wanted to see what he was doing and was interested to see how he put it all together. As I am interested in Python and am still quite new to the language, I was keen to take the course and willing to put in the time to complete it.

I joined in a little late, but made the deadline to register for the course. (He has an open enrollment “Python Playground” if you’d like to try it out.) I started, stuck to the assignments and completed all the assignments. (No certificate for this one. Just the satisfaction of completion.)

There were a number of things that impressed me about the course, but two things immediately jumped out at me:

1) The Size (the “M” in MOOC means “Massive“)

Dr. Chuck’s course has around 800 students enrolled. Compare that to the 49,000 in his Coursera course. (Or even compared to the 4,900 who completed it.) While that truly is Massive compared to any face-to-face university course, it certainly does not compare to the size of other online MOOCs. I’m concurrently enrolled – and thoroughly enjoying – MIT’s Learning Creative Learning, which has around 24,000 officially “enrolled” and many others who didn’t register in time but are following along.

Immediately, this got my attention and appealed. In the courses with umpteen-thousand participants, I’ve found it very hard to focus and identify with others. Joining a smaller, less massive, MOOC seemed much more manageable. It certainly allowed for more personal connections – and that really is key in any learning experience. (The MIT course has divided up participants in groups – both assigned and self-managed. That has made it a very valuable experience – I’m in a group with several colleagues and we can collaborate online or in person.)

2) The Licensing (the first “O” in MOOC means “Open“)

Dr. Chuck really believes in openness. He clearly says:

If you are a teacher and interested in reusing my materials, this is my plan:

  • My textbook is Creative Commmons Share Alike
  • All my lecture slides will be Creative Commons
  • All of my recorded videos will be up on YouTube and you can use them any way you like.

In one of his video lectures, he simply states: “I want to make more teachers! Use my stuff!”

Personally, I find this incredibly inspiring. Here’s a busy teacher embarking on a huge undertaking who makes it openly available and remixable. Rather than gain, he is truly focused on expanding people’s knowledge all around the world. This is really what “open” SHOULD mean in a MOOC: not just open for enrollment, but open for reuse.

Yes, I know there are differences of opinion. There are those who say that only some can afford to do this – those universities or professors who are secure in their positions and paychecks. It is possible that more open sharing of this sort will make it difficult for professors & teachers to get hired and for universities to fund R&D. I’m not ready to grapple with this issue at this time …but hope to at another date.

So, thanks to Dr. Chuck I now have some great resources I can use in having my own students learn Python. I also am inspired to put more of my own work out there with open licenses.

I’ve also learned a lot and have a lot to think about – not only related to the Python language, but also to course structure, incentives, pedagogy and more. It really was a fascinating class and I’m so glad I took it.

Instant Gratification: The Joys of Coding

I got up at 6 a.m. on Sunday morning to do some coding. I know some might think it sad, but it was a delightful hour.

I’m learning to program in Python through the Coursera course taught by a team of professors from Rice University. I know some Python, but I’m no programmer. The tasks are fairly easy but I find myself learning a lot: not just about the Python language, but also about online courses, how I learn, and the benefits of learning to program.

my stopwatch game

This morning I was finishing up a mini-project that was due at 8 a.m. It’s not a complicated program: a timer that you can turn on and off, with a game element of scoring points every time you stop it exactly on the second. Nothing Earth-shaking – I won’t be selling it as an app anytime soon! – but the process was very rewarding and illuminating.

I’d been working on the program for a couple of hours the other day, and had some frustrations. It kept blowing up on me, no matter what I did. I’d code something, run it and then the thing would wind up with a huge series of the same error message and lock up the system. I knew there was something going on with the timer in the program, but I couldn’t figure out what. I had started saving locally every version of the program, and having to open new windows (it’s a browser-based environment) and reload the code to work on it.

I then got more methodical in what I was doing and had more success without it blowing up. Eventually I got it about 75% working and shut down for the evening. This morning I got up and loaded up what I had saved, and the realization of what I had been doing wrong came to me clear as a bell: I’d been closing a window the program was drawing without resetting the program. That lock-up and series of error messages was the program shouting at me that I was doing things backwards. It’s amazing how a simple insight can come after walking away from a problem and clearing your mind. You come back fresh and look at things anew.

Now treating the interface properly, I was able to complete the other elements of the program, test them, and get everything running in proper order. The program runs, keeps score and works properly. (As long as you don’t close the pop-up window!) I submitted my assignment, feeling quite pleased.

Over my first cup of coffee of the morning, I reflected on it. I really do feel quite proud and happy about this simple little program. It’s quite amazing. The program itself is nothing to write about (you’re welcome to try it out) but I’m pleased as punch with it. Why?

I guess it’s that I faced difficulties and had to think my way through them. Something wouldn’t work right, and I’d have to figure it out. Apart from the interface blow-ups, there was the aspect of the timer counter that had to be tweaked (how do you get the minutes digit out of a counter that is in milliseconds?), figuring out how to ensure that the score wouldn’t be affected by mis-clicks, tweaking the visual interface, etc. Each time I encountered one of those I had to think it through: understand what was happening and what I had to do to change it to make it work correctly. I would change something, test it, change it again, test again – repeat until it was right.

And that process of code – test – tweak gives the same kind of feedback as you get from an addictive game: instant. You know when it’s right and you know when you’ve done something wrong. You’re rewarded with success for doing things right, and you get a failure when you do something wrong. No penalties – no bad grade – just instant feedback that it wasn’t right and you won’t get the reward until you do it correctly. Sure, it’s a bit of a Sysiphean task but so are all games – play Angry Birds for a while, why don’t you?

So I stuck at it until it worked right. And it does. I didn’t get a grade or even a score, but I got it right. And I did it myself. Can you tell I’m beaming as I write this?

Boy, this coffee tastes good this morning! OK, what’s next?