[Tutor] ideas for a simple program

Steven D'Aprano steve at pearwood.info
Wed Jan 26 04:18:53 CET 2011


walter weston wrote:
> 
> can I have some good ideas for simple programs,

What are you interested in? Find something you like to do, and write a 
program to help you do it.

Interested in maths? Write a program to generate prime numbers, or to 
search for amicable numbers. Look at Project Euler, although (in my 
opinion) the puzzles there are quite hard and require a lot of maths 
know-how.

Write a number guessing game. Or Hangman or Battleship.

Try the Python Challenge:
http://www.pythonchallenge.com/


More puzzle sites here, written in other languages but you can solve 
them in Python if you like:

http://sixrevisions.com/resources/10-puzzle-websites-to-sharpen-your-programming-skills/


Unfortunately, most of them seem to be aimed at people who aren't 
newbies. I think the world needs a good set of programming puzzles for 
beginners.

Write a program that asks the user to enter a word, then counts how many 
vowels and consonants are in the word.

Write a program to check the spelling of a word. (Easy.) Write one that 
makes suggestions for mis-spelled words. (Harder.)

Write a program that asks the user to type a message, and then converts 
it to Pig Latin. If you don't know what Pig Latin is, google for it :)

Write a program that asks the user for a list of numbers, separated by 
spaces or commas, and then calculated the total and the average.

A program that prints the time. Or how many days left until your 
birthday, or Christmas.

A program that counts how many palindrome numbers there are between two 
other numbers. (A palindrome number is one like 12321, or 473374.)

A program that sings (well, prints) the "There were ten in the bed" 
song. If you don't know it, it is a children's song. You start off by 
holding up ten fingers, or you can use actual children. You don't have 
to start with ten. Then you sing:

There were ten in the bed, and the little one said,
Roll over! Roll over!
And they all rolled over and ONE FELL OUT!
There were nine in the bed, and the little one said,
Roll over! Roll over!
And they all rolled over and ONE FELL OUT!
There were eight in the bed, and the little one said,
...

Well you get the idea. Eventually you've left with only the little one 
left, and the song ends:

There was one in a bed, and the little one said
Good night!

Or the 99 bottles of beer song. Google for it.

Or a program to find anagrams.

Write a program to find a random image on the Internet and display it in 
a window. This might be a little advanced for a beginner.

Or a program to find a random image on your hard drive, and display it 
in a window,

Write a program to simulate rolling dice, and print a histogram of the 
results.

Write a program that tests how random a sequence of supposed coin tosses 
are. If I say that I tossed a coin 20 times and got HTHTHTHHTTHTTHHTHTHT 
how likely is it that I'm lying?


-- 
Steven



More information about the Tutor mailing list