Beginner Python Practice?

Question:

Well just getting into the flow of thing with Python. Reading a few books, finding it fairly easy as I already have some experience with C++/Java from school and Python is definetly my favorite thus far.

Anyway, I am getting a whole bunch of information on python, but haven’t been putting it to much use. Thus, what I was wondering was if there are any sort of practice problems online that I can use? If anyone could point me in any sort of direction, I’d greatly appreciate it.

Asked By: TopChef

||

Answers:

Try Project Euler:

Project Euler is a series of
challenging mathematical/computer
programming problems that will require
more than just mathematical insights
to solve. Although mathematics will
help you arrive at elegant and
efficient methods, the use of a
computer and programming skills will
be required to solve most problems.

The problem is:

Add all the natural numbers below 1000
that are multiples of 3 or 5.

This question will probably introduce you to Python for-loops and the range() builtin function in the least. It might lead you to discover list comprehensions, or generator expressions and the sum() builtin function.

Answered By: fmark

The Python Challenge will not only let you exercise the Python you do know, it will also require you to learn about various popular third-party packages in order to solve some of the challenges.

I found python in 1988 and fell in love with it. Our group at work had been dissolved and we were looking for other jobs on site, so I had a couple of months to play around doing whatever I wanted to. I spent the time profitably learning and using python. I suggest you spend time thinking up and writing utilities and various useful tools. I’ve got 200-300 in my python tools library now (can’t even remember them all). I learned python from Guido’s tutorial, which is a good place to start (a C programmer will feel right at home).

python is also a great tool for making models — physical, math, stochastic, etc. Use numpy and scipy. It also wouldn’t hurt to learn some GUI stuff — I picked up wxPython and learned it, as I had some experience using wxWidgets in C++. wxPython has some impressive demo stuff!

Answered By: user387958

I always find it easier to learn a language in a specific problem domain. You might try looking at Django and doing the tutorial. This will give you a very light-weight intro to both Python and to a web framework (a very well-documented one) that is 100% Python.

Then do something in your field(s) of expertise — graph generation, or whatever — and tie that into a working framework to see if you got it right. My universe tends to be computational linguistics and there are a number of Python-based toolkits to help get you started. E.g. Natural Language Toolkit.

Just a thought.

Answered By: Peter Rowell

UPDATE (Jan 2020): There are many great online places to get beginner practice at Python, some which are highly engaging and/or otherwise interactive. These sites are generally more practical than the Python Challenge (http://pythonchallenge.com), which you can tackle later. (After years of experience, you can try the Python “wat” quiz). For now, it’s most important to learn, practice, and have fun. Welcome to Python!

ps. BTW (by the way), your experience puts you right in the heart of the target audience of my Python book, Core Python Programming. That audience is those who know how to code in another high-level language but want to learn Python as quickly but as in-depth as possible. Reviews, philosophy, and other info at http://corepython.com

pps. The following resources were previously on the list but are no longer available.

Answered By: wescpy

I used http://codingbat.com/ . A great website that not only takes one answer, like Project Euler, but also checks your code for more robustness by running it through multiple tests. It asks for much broader code than Project Euler, but its also much simpler than most Euler problems. It also has progress graphs which are pretty cool.

You could also try CheckIO which is kind of a quest where you have to post solutions in Python 2.7 or 3.3 to move up in the game. Fun and has quite a big community for questions and support.

From their Main Wiki Page:

Welcome to CheckIO – a service that has united all levels of Python
developers – from beginners up to the real experts!  

Here you can learn Python coding, try yourself in solving various
kinds of problems and share your ideas with others. Moreover, you can
consider original solutions of other users, exchange opinions and find
new friends.  

If you are just starting with Python – CheckIO is a great chance for
you to learn the basics and get a rich practice in solving different
tasks. If you’re an experienced coder, here you’ll find an exciting
opportunity to perfect your skills and learn new alternative logics
from others. On CheckIO you can not only resolve the existing tasks,
but also provide your own ones and even get points for them. Enjoy the
possibility of playing logical games, participating in exciting
competitions and share your success with friends in CheckIO.org!

Answered By: Samuel

Try this site full of Python Practice Problems. It leans towards problems that has already been solved so that you’ll have reference solutions.

Answered By: ldinh
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.