From Zero to Python Hero
December 10, 2009 7:26 PM   Subscribe

I'm interested in teaching myself Python as my first programming language. What kind of useful/interesting projects are recommended as a long term goal to work towards, given that I'm a total beginner?

I've been messing with the idea of teaching myself a programming language as a hobby, and after a bit of research Python seems to be the one best suited for me. That being said, I know absolutely nothing about programming, and I'm interested in what exactly I'd be able to accomplish after I've taught myself the basics. I've pulled together a number of tutorials and books, and messed around a bit with the extreme basics, and I've enjoyed it, but I feel that it would really help to motivate me if I had some kind of an end goal or project that I could work towards.

I would rate myself as a relatively advanced computer user, I like tinkering around with different programs and set ups to get the most out of machines. As a bit of background, I'm currently running a laptop on Windows Vista as my main PC, and a mac mini as an HTPC hooked up to my plasma, which I use mainly to run Plex for my movies and TV shows. Does anyone have examples of what they've been able to accomplish as a beginner after a few months of learning, or any suggestions on goals/projects that I can work towards? I realize that this is an extremely broad question, but I want to keep things pretty open so I can get a feel for what's possible. I've found the posts on Askmefi really helpful for tracking down resources and tutorials, but not much in terms of suggested projects. Any recommendations for books or training resources are also appreciated to help me get there.
posted by KilgoreTrout to Computers & Internet (21 answers total) 100 users marked this as a favorite
Whenever I learn a new programming language, I always code the following two things as a way to learn them:

Conway's game of life, and a Mandelbrot set viewer. They're both relatively simple tasks conceptually, but together they cover a pretty comprehensive range of programming features. If you figure out those two things, you can consider yourself basically fluent. Also, they're both awesome - I can mess around with the game of life forever, and the Mandelbrot is literally infinitely complex!

Have fun.
posted by Salvor Hardin at 7:33 PM on December 10, 2009 [4 favorites]

Get a book -- the Head First books are great. I'm a super-novice and Head Start C# is working out well for me (Python is definitely easier and more fun, though, as the syntax is much simpler and straightforward).

Be prepared to do ALL the exercises, though. Don't get ahead of yourself, because that's how you get lost.

I've found that Rock/Paper/Scissors with user input is a good first project for anything coding/scripting based (you can do it in Excel!).
posted by ®@ at 7:34 PM on December 10, 2009 [1 favorite]

Another note - with Python, I recommend doing the game of life first, because you can do it with just ASCII characters and you don't have to mess around with GUIs if you don't want to. The most common python GUI package (tkinter) is a bit of a pain sometimes.
posted by Salvor Hardin at 7:37 PM on December 10, 2009

Python is a great first language to learn. A long term goal—something like writing a competitive chess engine, for example—is something you'll probably acquire naturally as you spend time coding. You might want to start with projects that will take a few days or a few weeks, but are very doable for an absolute beginner—the kinds of challenges found at Ruby Quiz.
posted by paulg at 7:44 PM on December 10, 2009

Try the Python Challenge - it's a fun set of riddles and an introduction to Python at the same time.
posted by dragoon at 7:57 PM on December 10, 2009

How about interfacing with an API? Google, Twitter, Flickr, and Skype look fairly straightforward.
posted by djb at 8:02 PM on December 10, 2009

Start by automating any repetitive annoying tasks you find yourself doing.

The Game of Life is a good suggestion. And other little games (still using ASCII interfaces)

* Towers of Hanoi
* Tic Tac Toe
* Sudoku (Sudoku solver = extra credit)

Lots of software can be scripted with Python. You could write image manipulation scripts for GIMP or modify the AI in Civilization 4.

More advanced but totally feasible projects:
* 90's style "screensaver" programs: bouncing ball, spinning lines, etc (see PyGame)
* Write a spreadsheet program or a word processor (personally I like PyGTK for the GUI toolkit)
* Write a Jabber bot that can chat with you on GoogleTalk
* Write a FUSE filesystem (on the Mac)
* Write a basic web server

Also, comp.lang.python is a great resource
posted by qxntpqbbbqxl at 8:03 PM on December 10, 2009 [1 favorite]

I'll disagree with these folks and tell you to find an itch and scratch it.

Learning programming languages from a book is boring. Sure, you can do the contrived examples and pick up the basics, but you won't be having fun, and isn't that the point?

You will be much more motivated to learn when you're immediately applying what you learn to a problem at hand. So pick something that sounds cool.

Does it sound neat to write a little chess program? Could you use a to-do list that syncs online with Remember the Milk? How about a twenty questions game that learns the more you play it? Maybe you munge a lot of excel data every day and want to write some little scripts that simplify things and display pretty graphs.

Pick something that solves a problem or stimulates you intellectually, and then build it. You'll see how much fun programming can be.
posted by chrisamiller at 8:06 PM on December 10, 2009 [7 favorites]

What chrisamiller said. I suddenly developed an acute and consuming interest in Python for routine task automation the day I realized that my typing speed was the bottleneck to my entire office's rendering pipeline (don't ask)
posted by fairytale of los angeles at 8:17 PM on December 10, 2009 [1 favorite]

Project Euler is a nice place to start.
posted by shothotbot at 8:30 PM on December 10, 2009 [2 favorites]

Aren't Civilization IV scenarios all scripted in Python?
posted by bicyclefish at 8:37 PM on December 10, 2009

A great thing about Python is the huge variety of libraries and modules out there that make it pretty easy to get something cool up and running in a big hurry.

If you like gaming, give pygame or pyglet a look.

The Python Imaging Library is pretty cool if you want to build something like a tool to generate thumbnails or do batch processing of digital photos.

If you want to do something with GUIs, check out PyQt.

And, if you want to build something web-based, Google's App Engine is a really great way to get a web-based app up and running without having to deal with your own server.

Also, check out the Vaults of Parnassus.
posted by chbrooks at 8:59 PM on December 10, 2009 [1 favorite]

Two things I would say are very helpful:

1. The "Python In A Nutshell" book by Martinelli (blood and guts of the language and the standard library -- I'm a weirdo and like to read the language description/blood and guts first before tutorials and such. Your mileage may vary.

2. Code Like a Pythonista: Idiomatic Python by David Goodger -- a great guide to writing pythonic Python

Bonus 3rd thing:

3. PEP index on -- notably PEP 8 the style guide

Hope that helps.
posted by godisdad at 11:02 PM on December 10, 2009

Try to find a project that's something useful to you and at the same time fairly simple. If all useful things you can think of are complex, put them aside for later and start with something simple anyway.

Here are some ideas:

- Text wrangling. You can impress yourself with accomplishing a complex modification/filtering in just a few lines of code, this will help your motivation for further experiments. For example: read a large text file line by line and do some processing on each line and write out to a new file. Something that might take you many hours of dull labour to do by hand might take you minutes to code.

- Persistence. Write a small script that has a few settings that are saved on disk using shelve module and loaded again on startup. You will need this type of thing in many programs you'll write later on.

- Write a small command line interface: Do you want to do a) .. b) ... c) .. > [and then you type a or b or c and the script does something]

- It's very easy to do something relatively impressive with time module. Timer, alarm clock, stopwatch, clock that plays a chime once an hour (or half an hour). Since you programmed it you can easy add new features like turn timer into a project time tracker.

- It's also very easy to make something interesting with random module. For example, create a list of lists, each of them 80 single-char strings, each string is a random '.' or '~' character and then print them out, putting newline after each inner list. You have a random ascii graphical map that you can use in a number of ways. For example, think of it as a game map.. '.' is land and '~' is water. Can you change the algorithm to create a large body of water in the center?

- You can continue working on that map and turn it into a simple game - one ascii character is 'you', the script can take your input and move the character and then print out the map again, you can add other characters that will move randomly (or attack you or ...). You get the idea. In fact, just by programming games you can learn a very wide range of programming topics.

- look at winsound module.. it's very easy to have your script play a sound file - just one line.

Feel free to mefi mail me if you will have questions, I've been using python for 9 years, and very happy with it.
posted by rainy at 1:06 AM on December 11, 2009 [2 favorites]

Congratulations on your choice of Python as a programming language. I was in your exact position just a few years ago. You write: Does anyone have examples of what they've been able to accomplish as a beginner after a few months of learning. This is what I did as a first project. You might find it useful both as a source of inspiration for what can be done and, if you have just started, as a easy way to learn the basics of programming with Python.

I agree with what chrisamiller wrote: find an itch and scratch it.
posted by aroberge at 4:50 AM on December 11, 2009

Check if your library provides users with free access to the O'Reilly book catalog. I know here in Toronto it does and I had no idea. Spent lots of $ on books I could have accessed for nothing.
posted by jmmpangaea at 7:40 AM on December 11, 2009

Dive Into Python
Dive Into Python 3
posted by kirkaracha at 9:37 AM on December 11, 2009

Nth-ing Project Euler (if you dig math), Dive Into Python, and the Python Challenge. The latter is particularly helpful because it will gradually lead you through much of the standard library (the extensions that come bundled with Python).

Besides those, just try to write programs to help with your personal projects / explore your interests.
posted by silentbicycle at 10:24 AM on December 11, 2009

Find an open source project that's written in Python and see how you can help out. You can start by reviewing patches, or grab a bug that looks easy and see whether you can write a patch yourself.

Also, I bet you can find all sorts of repetitive tasks you can automate, as qxntpqbbbqxl suggested - Python's great for that. I've written a few quick scripts that go through folders full of files and move them into more appropriate folders, and things like that.
posted by kristi at 2:22 PM on December 11, 2009

One word of warning: learning a first language is different than learning another language (yay induction!). It might be a good idea to find a intro to programming textbook to work from, rather than a book intended for Yet Another Programming Language people. The reason is, they usually have a number of exercises for you to build upon the learning, whereas the project recommendations you're getting are going to pull in everything all at once. Not that such projects aren't fun, useful and inspiring, but having a set of projects in deliberately increasing complexity is useful for figuring out exactly what you need more review and practice with, ie recursion.

I wish I had a specific example in mind, so I'll just point out a book I found on amazon that I know has programming exercises: Python Programming: An Intro to Computer Science. Don't let the CS scare you away, I haven't seen a lot of proofs or analysis; even sorting algorithms are reserved for the final chapter. It has review questions and programming exercises to cover each chapter's topic. For example, I saw a Monty Hall simulator exercise, where you're asked to write a program simulating the Monty Hall Problem. It's counter-intuitive enough that I had a conversation with a fairly smart EE student about this and after I ran through cards, it became clear that switching was a winning strategy.

Also if you're interested in Django, the one project everyone does is a Blog. While I can't say it's imaginative, it's clearly possible.
posted by pwnguin at 9:33 AM on December 12, 2009

Here are a couple of free books for getting started with Python.

How To Think Like a Computer Scientist
Snake Wrangling for Kids (don't let the for kids part scare you - it's an incredibly useful intro to programming)
posted by COD at 9:50 AM on December 13, 2009

« Older Seeking either a) a specific n...   |  Can you help me with a formula... Newer »
This thread is closed to new comments.