Baby Steps in Data Journalism

Starting from zero, this Tumblr provides tools, links and how-to information for people just beginning to explore data journalism.
Posts tagged "programming"

New exercise (45) in Zed Shaw’s free online book Learn Python the Hard Way: code your own text game from scratch.

This time I’m using GitHub from the start. Made my first commit just a few minutes ago. The game skeleton is complete and can be run, but not much happens yet. 

Made my own game engine. It’s similar to Zed’s in ex. 43 but NOT the same. I’m happy about that. 

The last of my Python PPTs for journalism students:

This PowerPoint is a review of Zed Shaw’s exercises 27 - 34 in his excellent (HIGHLY recommended) FREE online book Learn Python the Hard Way.

See the course schedule for my journalism code course.

So I’m wrapping up a four-week Python module for journalism students, and each week I gave them a “self quiz” so they could see for themselves whether they really understood what they had studied in Zed Shaw’s Learn Python the Hard Way. Here they are:

Quiz 1 - exercises 0–12

Quiz 2 - exercises 13–19

Quiz 3 - exercises 20–26

Quiz 4 - exercises 27–34

Feel free to share. 

Zed’s exercise 43 in Learn Python the Hard Way really kicked my butt. I wish I had kept track of how many hours I spent on this. I know it was more than 20. But it was worth it.

My game is not only complete, but it runs without errors. I have tried every way I can think of to break it, and it just runs. I’m proud of my bomb timer that announces a countdown until the spaceship blows up. 

I guess all those weeks of playing Zork back in the 1980s were worth something after all. 

Some of the exercises in this set might seem tedious to you, but like eating your veggies, they are sooooo good for you …

This PowerPoint is a review of Zed Shaw’s exercises 20 - 26 in his excellent (HIGHLY recommended) FREE online book Learn Python the Hard Way

I made this PPT for my journalism students. See their course schedule.

Great book (and not only for kids): Python for Kids, by Jason R. Briggs.
At the website for the book, you can download the chapter about running turtle.

Great book (and not only for kids): Python for Kids, by Jason R. Briggs.

At the website for the book, you can download the chapter about running turtle.

I’ve looked at code, I’ve read explanations, I’ve been doing both on and off for years now, but the usefulness — the purpose — of object-oriented programming techniques just never sank in. 

Today is the day when I have, at last, understood. Ah.

I think I had enough programming knowledge (basics, foundation) to cross this gap long before today. It was a matter of application. 

What I did not do before now was read, and write out code, and read, and write out code, and repeat, and repeat. It has taken about four days, an hour or two each day. Before, it just seemed like so much extra work, extra planning, extra thinking, that was not necessary for the short programs I have written. And this is still true. It would be perfectly okay for many small programs to be written without objects, without classes. They will run, they will work, they will not have conflicts. 

Enter complexity. When a program is complex, when it must be longer than a few dozen lines — and if multiple people will all be writing code for it — then the brilliance of objects makes perfect sense. Because it’s not about making wheels for a car, or Person and Employee, or all those things that are used as examples in explanations of object-oriented programming and how it works. No. It is not about objects. It is about bundling. It is about re-usability. Extending. It is about preventing conflicts that arise when the same word might be used to mean two entirely different things.

Here is what finally made it clear for me:

First, Zed Shaw’s Learn Python the Hard Way, exercises 40 - 43. But not only those. Also what he asks you to do. I take Zed literally. When he tells me to go out on the Web and look stuff up, I do it. I read, I come back, I go out again. I take notes. I run code. I rewrite my notes.

Second, Python for Kids, by Jason R. Briggs, chapters 4 and 8. Chapter 4 is about turtle, a Python module that is often used to introduce children to programming concepts. Chapter 8 is about classes and objects, and partway through the chapter, when it’s talking about two giraffes, I realized the giraffes could be two turtles — which would be objects of the class Pen — and everything fell into place like pieces of a Tetris puzzle when you’re winning.

I had bought Briggs’s book to find out whether anything in it might be useful for teaching college journalism students Python. I had skimmed parts of it before. I ran all the suggested code in the turtle chapter because I had never used the turtle module before. But I had put the book aside a few months ago.

Then I was diligently working through Zed’s exercise 42, and I’m thinking: Classes, Attributes. This is like CSS. This is like jQuery. I see the structure, it’s starting to seem familiar … And then I remembered Briggs’s book. I went back to his chapter 8 and read. 

And there it was. 

Don’t give up. I think this is the greatest lesson taught by learning to program. We are rewarded again and again for our hard work, sticking to it, trying and failing and trying again. We might become stuck for a time, but we can figure out a way to become unstuck if we only continue trying. 

macloo:

Code is for everyone! 

macloo:

Nice. 

macloo:

Nice. 

(via macloo)

macloo:

Craig’s book is one of best teaching and learning resources that I’ve ever seen for any subject. It follows the Python lessons in Codecademy (one of the best online learning resources out there) and then reinforces these skills using Raspberry Pi Minecraft. It’s contemporary and it’s challenging and it’s fun. It’s got a 225 page student book with exercises plus separate teachers’ notes. It provides differentiation and it references the new Computing curriculum. It’s learning by stealth.”

Must. Look. 

codeorg:

image

By Hadi Partovi, founder, Code.org

Throughout Code.org’s achievements in our first year, I’ve been humbled by support from millions of students, parents, teachers, companies and other organizations.

But we’ve also been thrust into the spotlight. Understandably, some have misunderstood…

A nice, clear explanation on what Code.org is trying to do. And why. 

Play, play, play — that’s my advice for how to learn to code.

I’m a big fan of Zed Shaw’s Learn Python the Hard Way, but I think exercises 13–19 are a particularly challenging hurdle to jump if you never studied any kind of programming before. 

So here are three supplements to help:

Files to help with from sys import argv

Files to help with learning functions 

A self-quiz for exercises 13–19 

Have at it!