Here's one that I actually wrote for home use cataloging several thousand pictures:

Write a program to scan a user-supplied directory for .jpg files. Then, output the list of files, sorted by date picture was taken, as an HTML file with hyperlinks to each pic.

Bonus points: make the scan recursive so that all subdirectories are scanned also.

Double Bonus points: make it possible to run your program a second time, supply a different directory, and add to your list of pictures. A couple of things about this one are non-trivial!

You will need a module to help you read the .jpeg metadata. See here:


If you have similar text files, write a program that shows which lines of text are different. Hint: module difflib has a few tricks up its sleeves.

This little code gives you the hour, minute and second of the present time:

# get just hr, min, sec of present time tuple:
import time
hr, min, sec = time.localtime()[3:6]
print hr, min, sec

Use this to create an alarm timer in Python that plays a wave sound file when the set alarm time has been reached.

The word game Scrabble has a total of 100 letter tiles. I listed a dictionary of the letters in the game showing the letter and a tuple containng the frequency of the letter and its value.

# scrabble letter (frequency, value) total 100 tiles
# from
scrabbleD = {
'A': (9, 1),
'B': (2, 3),
'C': (2, 3),
'D': (4, 2),
'E': (12, 1),
'F': (2, 4),
'G': (3, 2),
'H': (2, 4),
'I': (9, 1),
'J': (1, 8),
'K': (1, 5),
'L': (4, 1),
'M': (2, 3),
'N': (6, 1),
'O': (8, 1),
'P': (2, 3),
'Q': (1, 10),
'R': (6, 1),
'S': (4, 1),
'T': (6, 1),
'U': (4, 1),
'V': (2, 4),
'W': (2, 4),
'X': (1, 8),
'Y': (2, 4),
'Z': (1, 10),
'blank': (2, 0)

# test it ...
print "%6s %6s %6s" % ("letter", "freq", "val")
print "-"*24
for letter, (freq, val) in scrabbleD.iteritems():
    print "%6s %6s %6s" % (letter, freq, val)

You can use this information to write a Python program to play Fastscrabble, a variation of the game that can be played without a board. The rules are simple:

All 100 tiles are laid on the table face down.

Each player takes a turn to expose one tile.

If any player can make a word from any of the exposed tiles, he/she says "scrabble", sets the tiles of the word aside, and counts the values to his/her score.

Players who yell "scrabble" and can't make a word get a ten point deduction from their score, or have to remove one article of clothing.

The game is over when all tiles are exposed and no more words can be formed.

The following little Python code will bring up your default webbrowser and connect it to the given URL ...

import webbrowser
# you have to be connected to the internet
# supply a URL of your choice'')

You can write a Python program that picks a URL from a list of fun URLs at random and be surprised what comes up.

You can produce Python code riddles and have your peers guess what the result will be. Here is an example ...

# a Python code riddle, can you figure it out?
print chr(98) + ''.join (['natural fruit'[:2][int(i==0) : 2+int(i==2)] for i in range(3)])

Click on "Toggle Plain Text" so you can highlight and copy the code to your editor.

Use Python code to write a digital stopwatch program.

Write wxPython image viewer. Most of the information needed is already in the Python snippets here at Daniweb.

First create list of all image files (like .jpg, .png) in given folder. Go through the list with a next and previous button to display the selected images.

Much of the image info is in

I have put together a dictionary of the Morse code:

morseDict = {
'A': '.-',
'B': '-...',
'C': '-.-.',
'D': '-..',
'E': '.',
'F': '..-.',
'G': '--.',
'H': '....',
'I': '..',
'J': '.---',
'K': '-.-',
'L': '.-..',
'M': '--',
'N': '-.',
'O': '---',
'P': '.--.',
'Q': '--.-',
'R': '.-.',
'S': '...',
'T': '-',
'U': '..-',
'V': '...-',
'W': '.--',
'X': '-..-',
'Y': '-.--',
'Z': '--..'

# test it
print morseDict

Write a Python program that takes a text string and converts it into a string of Morse code characters separated by a space.

If you have a PC with Windows OS, then you can sound off this string on the internal speaker:

# if you have a computer using Windows you can 
# sound a morse code string off on the internal computer speaker
# using winsound.Beep(frequency-cps, duration-ms)
# you can experiment with tone frequency and duration
import winsound
import time

morseStr = "--.. ..- .-.. ..-"  # ZULU
for c in morseStr:
    print c
    if c == '-':
        winsound.Beep(800, 500)
    elif c == '.':
        winsound.Beep(800, 100)
        time.sleep(0.4)  # rest between each letter
    time.sleep(0.2)      # rest between each dash/dot

A much more complicated project would be to catch Morse code (microphone?) and convert into an alphabetic string.

This goes along with vegaseat's Python code riddles. Hide your email address in Python code like this clever example shows:

print "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz")

Write a program that maintains a list of things you have to do, want to do, should have done and have done. You ought to be able to sort this list by importance, time left, and certain keywords amongst other things. You get the drift! Could be a great time organizer.

Write a Python program using the Tkinter GUI that shows a series of buttons with the names of your favorite programs. Click the button to launch the program. Would be great for all your games on the PC.

The short Tkinter GUI code wll draw one yellow circle on the canvas:

from Tkinter import *

root = Tk()
root.title("Tkinter Circle")

canvas = Canvas(root, width=400, height=400)

# yellow circle is drawn within square with corner 
# coordinates x1=50, y1=50 and x2=350, y2=350


Your challenge will be to draw one archery target consisting of 5 concentric circles going from yellow center to red, blue, black, white.

As added challenge draw the 64 square chess board using the GUI of your choice. I like wxPython, but Tkinter will do.

Construct a keyboard using a GUI like Tkinter that allows you to type by clicking on the displayed keyboard keys.

This little code shows 6 random integer numbers from 1 to 50 ...

import random

print "show 6 random integers from 1 to 50:"
for k in range(6):
  r = random.randint(1, 50)
  print r,

Rewrite the code to make sure there are no duplicate numbers amongst the six numbers displayed.

Now let the user enter six unique numbers from 1 to 50 and then count how many tries it takes the computer to match 3, 4, 5 or 6 of the user's numbers, using the above random number example. You might recognize this as a way to figure out the chances to win a lotto game.

You have a number of sentences of similar structure like ...

str1 = "The mouse jumped over the green frog"
str2 = "The sailor fell into the dirty pool"
str3 = "The maid ran through the dark house"
str4 = "The dog chased after the quacking duck"
str5 = "The cat leaped across the white fence"

Write a Python program that interchances lets say all the second words of each sentence. You can interchange at random all the words in matching positions. Could be fun to read the results!

Just another simple word game! Write a program that picks a letter from a to z at random. Now show the player the starting and ending letter of a word and ask to fill in "the between" to form a single word. The player is scored by the number of letters used in the word.

To fancy up the game you could search for a match in the english dictionary attached to:

A simple guess the word game. This Python program takes a word and shuffles the characters, asking you to guess the original word. You could pick a word at random from a list of words and make a nice game.

import random

str1 = "Mississippi"
# convert to a list of char
charList = list(str1)
# shuffle the char
# convert back to a word
str2 = "".join(charList)
# and show it ...
print "Guess this word --> %s" % (str2)

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

How can you display this text with just a one line statement?

Hint: Think about this!

My effort to create some simpler Python projects:
Take sentence (text string) and replace all the lower case vowels with upper case vowels.

Another simple Python project:
Write head/tail coin toss program. Test it with about 1000 tosses and see if head or tail prevail.

Take the english dictionary attached to:
and find out the words that are palindromes (spell the same forward and backward), or which words form other words in the dictionary when spelled backward.

Hint ...

# slicing operator seq[begin : end : step]  step is optional
# defaults are index begin = 0, index end = len - 1, step = 1
# step = -1 reverses sequence

str1 = 'ten'
str2 = str1[::-1]

print str1  # ten
print str2  # net

Write a function that takes a block of text and returns the text formatted with the specified indentation and specified maximum total length of each line. Should properly wrap the words.

Our friend chris99 gave me this idea about a colorful project. You can get the country flags of the world from:
Now take a Tkinter canvas and draw some of these flags. Here is an example for Japan:

from Tkinter import *

root = Tk()
root.title("Flag of Japan")

canvas = Canvas(root, width=400, height=300, bg='white')

# red circle is drawn within square with corner
# coordinates x1=100, y1=50 and x2=300, y2=250
canvas.create_oval(100, 50, 300, 250, fill='red')


The national flags for France or Germany would be easy to draw using rectangles. Finland or Switzerland would be a little more difficult, and the US, Canada or UK could be real challenges.

Here is an example of the classical "Guess a Number" game:

# guess a number game ...

import random

x = random.randint(1,100)

total = 0
while True:
    guess = int(raw_input("Guess a number between 1 and 100: "))
    total += 1
    if guess == x:
        print "Correct in %d guesses!" % (total)
    elif guess < x:
        print "Too low!"
        print "Too high!"

Now improve the game, by telling the user not only "low" or "high", but also how close by selecting from a list like ["very hot", "hot", "warm", "cold", "very cold"].

If you had a sorted list like ...

name_list = ['Amy', 'Bia', 'Dee', 'Eva', 'Gin', 'Ivy', 'Joy', 'Kay', 'Pam', 'Ute']

... and wanted to add the names 'Erin' and 'Kim' into positions so the list remained sorted, how would you do it?

Below is a short Python code example that allows you to add new words to a list of words. The word list can be loaded, updated and saved:

# add new words to a word list, uses module pickle to load and update an 
# existing word list file, starts with an empty word list if no file exists

import pickle

filename = "wordlist.dat"

    file = open(filename, "r")
    wordlist = pickle.load(file)
    print "Present word list from file %s:" % filename
    print wordlist
    original_length = len(wordlist)
except IOError:
    print "Present wordlist is empty!"
    wordlist = []

while True:
    answer = raw_input("Write some words (nothing to exit): ")
    if answer == "":
    words = answer.split()
    for word in words:
        if word not in wordlist:
            print "'%s' added to word list" % word
            print "'%s' already in word list" % word
# optional sort
print wordlist

# check if a change has been made ...
if original_length < len(wordlist):
    # pickle/update list before exiting
    file = open(filename, "w")
    pickle.dump(wordlist, file)
    print "File %s has been updated!" % filename

Do a similar thing that allows you to build a dictionary of key:value pairs where
the key is the name of a person and the value is the phone number, or the name
and the address of a person, or a programming language keyword and a short
example of its use, or the name of an element and the symbol of the element.

The nice thing would be, that you can take time to create the dictionary and
later use it in a program of your own.

Here is Python code to find when a file has been last modified:

import os
import time

# pick a file you have in the working directory
filename = "test.txt"

print "Last modified time of file:", filename
print time.ctime(os.path.getmtime(filename))

# or 24 hour format eg. 06/28/2006 05:04:19
print time.strftime("%m/%d/%Y %H:%M:%S",time.localtime(os.path.getmtime(filename)))

# or 12 hour format eg. 06/28/2006 05:04:19 AM
print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(filename)))

You could use this information to write a program that will scan your harddrive or a directory, and display all the files that have been modified in the last 24 hours.

Create an index dictionary of a text such that the starting letter of the word forms the index/key associated to a list of the word(s). For instance ...

text = "The ingenuity of fools will fool any foolproof system!"

would turn into a dictionary like ...

{'a': ['any'], 'f': ['fools', 'fool', 'foolproof'], 'i': ['ingenuity'], 'o': ['of'], 's': ['system!'], 't': ['the'], 'w': ['will']}

Note, that the words are lower case. You could further embellish the result by removing punctuation marks from the word.

If you have simple English word like:

str1 = 'supercalifragilisticexpialidocious'

How would you form string that has every second letter in capital (upper case).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.