Thursday, December 15, 2016

Programming Projects for Beginners - Python

I had signed up to teach programming as part of the Hour of Code movement to middle/high school kids and was pondering on what would be good and interesting programming exercises for beginners.  That got me thinking about simple programs that beginner students can write and feel proud about learning programming constructs and see them used in constructive ways.

After some thinking, here are five simple programming exercises that I came up with.  Each of these can be completed within an hour.

Note that I have solved these in python and will be including the screenshot of the output to give you an idea of how the program behaves and handles errors.

Python is a simple high level interpreted programming language with a rich set of libraries which makes it easy for beginners to learn. You can learn python here as well as run it in an online interpreter.  I often use repl for an online python interpreter. For some exercises, you will need to install python locally and run your programs.  We will go into the details later.

1. Texting monitor: This was inspired by Shark Tank episode where Trisha Prabhu pitched her app 'ReThink' to stop cyber bullying.  As soon as I saw it, I thought a beginner could write a simple program to mimic what she is doing.

2. Guess the number: This is a game where the computer selects a random number (say, between 1 and 100), and the user guesses the number.

3. Email validator: We have all filled out forms where your email is requested.  In most advanced forms, as soon as you type your email, in case you made a mistake, the form would indicate that something is wrong.  This program does exactly that.  It checks the input text to ensure it is a valid email address.

4. Hangman game: This is the classic hangman game where the user guesses the chosen word in a given number of tries.

5. Bubble sort: This exercise will introduce you to sorting a list of items.  Sorting is the process of placing the elements in a collection in a specific order.  In our case, we will sort a list of random integers into a list that contains the numbers in an ascending order.

I will post more details of each of these exercises in the coming days.  Look for those posts.

Happy coding!