top | item 11213226

Python Exercises for Kids

137 points| ingve | 10 years ago |blog.regehr.org | reply

37 comments

order
[+] dkopi|10 years ago|reply
Started programming when I was 8 using basic. Things have changed a lot since then, but one thing probably hasn't: The best incentive I got to continue learning how to program was my ability to impress others.

I would develop screen savers (Lines floating on the screen, lines being drawn randomly on screen, ball bouncing off the edges of the screen, flying into a star-field as the stars move away from the center of the screen), and show them off to my friends and family. I would develop a small game (spaceship moves up and down to avoid hitting incoming asteroids) - I'd show it to my friends. Let my brothers play the game.

These were the type of rewarding tasks that led me to keep on learning and experimenting.

If you're doing Python - I strongly recommend "Inventing computer games with python" https://inventwithpython.com/ Using pygame, you can get really quick graphical results, and start showing off some awesome things. I even built a Tetris game based on pygame a while back when I was learning python myself.

Also - if you're doing turtle programming, check out http://pythonturtle.org/ - an awesome implementation of turtle graphics for python.

[+] neosat|10 years ago|reply
That matches a lot of my experience. I created a bunch of those lines floating on the screen which never failed to impress classmates who didn't frequent the computer lab and were stuck doing "write a program to calculate compound interest".

My neatest trick at that point was to make a 'fake' pre-loader where the progress bar showed a fake percentage with a cool graphic. My next 'impress project' was build a menu in QBasic where you could use the arrow keys on the keyboard to graphically move the highlighter on a menu. Almost everyone else at that time was doing menu selection pressing the number of the menu item. At that point I thought of it myself since there wasn't any internet in our lab so I still feel really good about it :) It also got me a spot on our school programming team primarily because no one else did the menu as quickly as I could then.

I'd like to think that I'm an interaction designer today partly because of the feedback and enjoyment I got out of doing projects like that.

[+] dr_zoidberg|10 years ago|reply
I agree with you since I had a very similar story with computers. Some day my brothers and I discovered the computer had something called QBASIC and it had a few games, which we then noticed you coudl change and totally mess up. And it had a HELP that explained everything! And it had a way to do prettier graphics than what NIBBLES.BAS and GORILLA.BAS had! Eventually my older brother found the QBASIC compiler and we kept copies of that floppy just in case some failed.

When I got older I did a few things in C, but didn't get the chance to go too deep much into it because when I started university at 18 I pretty much stopped programming for fun, until my graduation project began and I got in touch with Python.

[+] harryf|10 years ago|reply
Most "Teach Kids Programming" are build on the idea that programming means sitting still in front of a keyboard typing stuff. Most kids under 10 can manage at most about 15 minutes of that before getting bored and either wanting to get up and jump around or watch YouTube / play games.

Scratch (https://scratch.mit.edu/) helps a bit but it's still "stuck in front of a screen" and reaching a "reward", in terms of a meaningful result takes longer than the average childs attention span.

Best starting point I've ever seen is this "How to Train your Robot" real world game - https://drtechniko.com/2014/07/09/teaching-the-how-to-train-... - which is based on the idea that adults play the robots and kids get to tell them what to do. That's immediately a fascinating starting point for kids to hold their interest while they pick up some basic ideas of logic and creating instruction sets for a 3rd party to execute.

[+] maroonblazer|10 years ago|reply
There was an iOS game out about 5-ish years ago where you did essentially this. You had a robot on a small grid/map with a start and end point. The objective was to get the robot from the start to the end. You had a set of icons/commands, each one indicating a different instruction (step forward, turn left, turn right, jump, etc) that you used to navigate the robot. Successfully completing each map unlocked a more challenging map with more steps and obstacles to avoid.

It also gave you a way to combine a set of instructions into what was essentially a function/method so that you could then call the function/method instead of retyping all the steps. My kid was too young at the time but now that he's older I can't find it or it was never updated.

Anyone happen to know of this app, or something similar?

[+] jvvw|10 years ago|reply
Attention span varies considerably from one child to another.

The 'How to Train your Robot' game appears to be aimed at a 2.5 year old and as the mother of a 2.5 year old myself, it seems ludicrous to try to get a child that age into programming.

On the other hand, my 5 year old needs something more than directing robots around - Robot Turtles is too easy now for example, but he does enjoy playing with ScratchJr on the iPad, sometimes for quite long periods of time. It also of course has the big advantage at this age of not requiring literacy.

[+] eugenekolo2|10 years ago|reply
I'm sorry but I don't see how these are for kids. "Monte Carlo Pi Estimator" ??

Some stuff kids would enjoy more: https://inventwithpython.com/ http://www.amazon.com/Python-Kids-Playful-Introduction-Progr...

[+] thomaskcr|10 years ago|reply
It's just a fancy way of saying what it really is (estimating pi with increasing accuracy using geometry). I remember doing the pencil circle drop calculation for pi in middle school which is a similar concept just physical instead of on a computer.

The problem I've found with pygame is that the time from starting to producing a playable game is too long, the kids get frustrated and lose interest when you need to type 20-40 lines of boiler plate to just get an image and a moving character on the screen before anything even happens. I've had much greater success with "boring" projects that produce the final result in 10-20 lines.

They already have games that we'll never be able to come close to in terms of quality. There's nothing that I can make in even 20 hours that is even close to as interesting as Minecraft or a high budget xbox game - there is effectively a very small difference to them between building a game with "boring" dynamics and solving math problems.

This mostly only applies to first projects, once you complete a few projects and have separated out the children who actually enjoy programming - that's when you can start doing multi-week epics. But you need to build confidence and give them some easy "wins" before you are going to be able to do that in my experience.

[+] raymondh|10 years ago|reply
There are much better resources for kids to learn Python. I recommend Chris Roffey's excellent series of Coding Club books. They are engaging, well-written and have more meaningful exercises.
[+] truebosko|10 years ago|reply
This is great, thank you! I teach a weekly Python class to kids and have been slowly refining my curriculum (Shameless plug, the Sphinx docs are up online here for anyone to critique! http://justbartek.ca/python-curriculum/)

One of the more popular exercises thus far for us has been the "Bagels" program. I can't even remember where I found the game, but they find it a lot of fun as it mixes a bunch of mental challenges into one program.

http://justbartek.ca/python-curriculum/exercises/bagels.html

[+] truncate|10 years ago|reply
Back when I was kid, I chose Flash programming over C++. It was just more fun, with results that you could show off to your friends. I didn't care how things work, I just wanted to build stuff. Once I started building tiny little games, I automatically started to learn how things work and developed interest in the science behind it, be it maths, physics or computer science itself. Today, I would suggest Racket's big-bang.

[1] http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%2...

[+] jredwards|10 years ago|reply
Would be an awkward title if you weren't familiar with software development.
[+] DanBC|10 years ago|reply
I always thought fractals and similar were great introductory programs for children.

The fractals need only a few lines of code, with a bit of extra boiler plate. Tweaking the formula can give dramatically different results. You get to use a variety of programming concepts in a short program.

Relevant books are

Dynamical Systems and Fractals (Karl-Heinz Becker, Michael Dörfler) (This book has extensive Pascal code) http://www.amazon.co.uk/Dynamical-Systems-Fractals-Computer-...

http://ebooks.cambridge.org/ebook.jsf?bid=CBO9780511663031

Fractals - Images of Chaos (Hans Lauwerier) (This book has an appendix of BASIC code) http://www.amazon.co.uk/Fractals-Images-Chaos-Penguin-Scienc...

Sadly neither book is suitable for general 11 year olds, but a modern version certainly could be.

And A.K. Dewdney obviously has a bunch of books which could be used to inspire young programmers. The Armchair Universe, or The Magic Machine and similar launched many programmers, with "Core War", "Wator", "Bugs", etc

[+] jferge|10 years ago|reply
These are all way too hard for an average 11 year old...
[+] timthorn|10 years ago|reply
I doubt it very much. Children have an amazing capacity to learn and are usually constrained by adults thinking that kids can't cope with more than simple challenges.
[+] ansjun|10 years ago|reply
Slush Smackdown is also a fun way for children (not maybe for the youngest children) to learn to code. It is not in Python though. Basically you code your wrestling moves in Javascript and begin fighting against other people's code http://slushsmackdown.com/
[+] tsumnia|10 years ago|reply
I remember growing up wanting to build AOL chatroom bots, nothing like Eliza, but trivia or combat bots - maybe around the age of 11-12. Though a bit dated, an IRC trivia bot might be a fun exercise for them.

Or a text-based adventure to teach arrays. They build the map, then move through it in the same manner.

[+] arsalanb|10 years ago|reply
The title kind of assumes all kids are amateurs. I feel age has nothing to do with programming prowess. I may sound like I'm nitpicking but it should be "Python Exercises for Beginners".

These exercises can be too tough for a 50 year old beginner, and a 15 year old can breeze through them.

[+] justifier|10 years ago|reply
it's my opinion that the future of programming education will be compulsory and simply folded into mathematics education

python exercises for kids? their math homework

[+] timwaagh|10 years ago|reply
congratulations on having a very smart kid.
[+] gragas|10 years ago|reply
I don't see this working well with kids. I'm a course assistant for an introductory Python course at a {top 5} CS school. It's shocking to see the sheer lack of intuition and inability to think about loops some beginners have.

Although now that I think about it, I think I'd trust a 13-year-old with a fresh mind more than most of the college students I work with.

[+] ArcticCelt|10 years ago|reply
I teach myself to program in basic when I was 10 without the assistance of any adult an made my own "for loops" because I only knew "GOTO", "IF" and variables. You can do a lot of shit with only "GOTO" and "IF", I made a Black Jack game. :)
[+] dkopi|10 years ago|reply
I sometimes think the best way for people to learn about loops is not to tell them they exist at first. Give them lots of repetitive assignments, (print the numbers 1 through 50, or all the powers of 2 until 65536) until they're so frustrated they start demanding a solution.