share
Stack OverflowPython exercises to hone your skills
[+128] [9] Jiaaro
[2008-08-27 05:16:26]
[ python ]
[ http://stackoverflow.com/questions/29578/python-exercises-to-hone-your-skills ] [DELETED]

Is there a place with little coding projects you can do to hone your skills? Preferably with answers to compare your code to and/or look at if you can't figure it out.

a good example of such a site is http://www.hackthissite.org, which has little web security tutorials to help you learn about vulnerabilities and ways people might hack a (your) website.

For me one of the biggest things when becoming familiar with new modules etc is trying to use them and looking at other people's code. Unfortunately many times there is no sample code in the documentation.

edit: Here's what I've found so far, organized by difficulty...

Absolute Beginner

Moderate Ability

Complex Programming Problems

Havn't found any

(5) "Complex Programming Problems: Haven't found any." (lol) I've got one for you: crack RSA encryption in polynomial time. That's more of a math challenge though. - Dan Burton
(9) Why not ask him to prove P != NP, while you're at it? - Tom Zych
I would suggest markandclick.com - Michael
(2) check checkio.org - thavan
(3) Try tests4geeks.com/test/python. It's not a coding test, it's a quiz. But it has interesting questions with Python code samples. Could be a good tool for preparing to an interview. - Alex
I don't know what the hackthissite is, but for security challenges (though I don't think they do tutorials) I use http://smashthestack.org - matts1
[+56] [2008-08-27 05:58:52] jeremiahd [ACCEPTED]

Python Challenge [1]

Project Euler [2] - when you answer a question, you are able to see and discuss other peoples solutions.

ACM programming challenges [3]

Some python problems focusing on science / math [4]

[1] http://www.pythonchallenge.com/
[2] http://projecteuler.net/
[3] http://icpc.baylor.edu/challenge/
[4] http://web.archive.org/web/20100808125507/http://cse.ucdavis.edu/~chaos/courses/nlp/Software/PythonProgramming.html

(2) The ACM link is out of date -- here's the current location. - Janusz Lenar
Thanks! Updated. - jeremiahd
the last link is broken. - John
(1) Thanks, @johnthexiii . I updated it to point at the last wayback machine snapshot. - jeremiahd
1
[+26] [2011-02-08 02:12:56] tkc

Pyschools [1]

This website has 100 over practice questions for learning python.

[1] http://www.pyschools.com

i really liked this site a lot! - super9
2
[+10] [2008-08-27 05:54:30] postfuturist

I honed my Python skills by participating in PyWeek [1]. It's a competition to make a video game in one week with Python. It's a friendly competition, the people are very helpful, and its a great way to get motivated to learn general, object oriented Python. Many of the entrants code their games in PyGame, a 2D (mostly) game library for Python.
Most of the programmers I've worked with have at some time entertained the idea of making video games, and it's how a lot of us got into the industry to begin with. Python + game programming = fun while learning.

[1] http://pyweek.org/

3
[+8] [2008-08-27 05:21:45] SCdF

http://osix.net/modules/geek/ is good for random coding challenges, you also can solve in a language of your choice.


4
[+8] [2008-10-19 10:38:14] Andrea Ambu

Try to solve Google Code Jam [1] problems in python. Small and big input files. Start with practice contest then move on hardest contest, there are really hard problems ;)

[1] http://code.google.com/codejam/

looks like fun... so does google get to use/keep your solutions at the end? haha - Jiaaro
Only if you take part of the competition. Solutions submited in "practice mode" will not be stored :) - Andrea Ambu
5
[+6] [2011-09-14 12:29:14] tsimbalar

Check out Python Koans [1] !

The idea is to make some unit tests pass, step by step. It is actually quite fun to do (although a bit basic).

Here is the description :

Python Koans is a port of Edgecase's "Ruby Koans".

Python Koans is an interactive tutorial for learning Python by making tests pass.

Most tests are 'fixed' by filling the missing parts of assert functions. Eg:

self.assertEqual(__, 1+2)

which can be fixed by replacing the __ part with the appropriate code:

self.assertEqual(3, 1+2)

Occasionally you will encounter some failing tests that are already filled out. In these cases you will need to finish implementing some code to progress. For example, there is an exercise for writing some code that will tell you if a triangle is equilateral, isosceles or scalene.

As well as being a great way to learn some Python, it is also a good way to get a taste of Test Driven Development (TDD).

[1] https://github.com/gregmalcolm/python_koans

The link is now fixed. - tsimbalar
6
[+3] [2008-08-27 20:33:36] Peter Hoffmann

Albeit the ICFP Programming Contest [1] is not really for little coding projects, the last problems were always interesting and you can compare your python program to programs in other languages.

[1] http://en.wikipedia.org/wiki/ICFP_Programming_Contest

7
[+3] [2010-12-14 14:57:57] Oren S

FWIW, Google have started a " code university [1]" and it contains a very nice section about python [2], with written material, video lectures and some exercises...

[1] http://code.google.com/edu/
[2] http://code.google.com/edu/languages/google-python-class/index.html

8
[+2] [2011-03-16 03:59:52] Rodrigo

Just found this: http://singpath.appspot.com/about

Seems to take you through levels of problems to solve with Python, in a game fashion. Haven't tested it yet.


9