Let's assume you are working for the NSA and wanted to use Python to profile large amounts of e-mail that you are intercepting.

Write three fictitious e-mails, one a business e-mail, one a love/romance e-mail and one e-mail from Ladun Bing Osman to an accomplice that threatens your country.

Now use Python's text handling prowess to profile the three letters, so the dastardly letter can be identified. Check if fragments of words can do this.

Note: As of this time there are over 10 billion (yes, billion!) e-mails each day worldwide. Would be tough to read them all in person! To this you can add about 15 billion spam e-mails!

Design a text driven adventure game. Draw a map with features like meadows, woods, mountains, rivers, lakes, caves, cottages and such. You know the map, the player does not! Start in the center and give a description in all directions.

Ask the player which direction she/he wants to go (E,W,S,N). Keep descriping the new environment according to your map and ask player for directions to go.

The goal is to find a treasure hidden somewhere on the map(give hints on how close the player is) and then find the way back to the start. Hopefully the player can remember some of the more distinctive features along the path taken.

hehe bumsfeld, sounds like a MUD your describing there ;)

i got one for all you maths nuts out there...

re-invent the wheel!!!!

well not quite, the challenge is quite simple, make an algorithm or function or whatever that returns the square root of any number, WITHOUT USING ANY INBUILT SQUARE ROOT FUNCTION!!!!!

so essentially, re-invent the wheel.:mrgreen:

have fun guys,
a1eio

:lol: this will help me alittle bit i appreciate it im new to this place :) :)

Looking around the internet, I haven't found a nice hangman game yet written in Python. You can use a simple ASCII character graphics or go fancy with a GUI drawing canvas (Tkinter or PyGame). Might even be able to use a chopped up image and hang your less favorite politician or used car dealer.

An electronic version of an Index Card File would be interesting, like a collection of recipes for cooking. You could search quickly using a limited set of keywords/titles, or slower using the general text of each card.

If you want to be fancy, you can add a feature to cook for two people, five people or even 12.

I am thinking about a "snappy comeback" program. You enter a question and the program analyses the question for certain verbs or nouns and tries to come up with an answer. Could be silly or fun!

Create a number to word converter, you type in a number like 1776 and your program returns the number spelled in words (English or whatever language you like). Should be a simple project and a good exercise for your Python skills.

For an additional challenge, could be expanded to spell out something like \$1,545,299.45!

Just to help you out with the somewhat larger numbers, here is some Python help ...

``````# english words for multiples of thousand
thousands = [
"thousand",
"million",
"billion",
"trillion",
"quadrillion",
"quintillion",
"sextillion",
"septillion",
"octillion",
"nonillion",
"decillion",
"undecillion",
"duodecillion",
"tredecillion",
"quattuordecillion",
"sexdecillion",
"septendecillion",
"octodecillion",
"novemdecillion",
"vigintillion"]

t = '1,000'
for s in thousands:
print "%-18s %s" % (s, t)
t += ',000'``````

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

Just a silly program, take a text and reverse the starting and ending letter of each word (having 2 letters and more), then see if you can still read it. Test it on your friends. Don't overdo it, or you will not have any friends left!

If you can read that result easily, go on and reverse the first two with the last two letters of each word (4 letters and above). Or reverse letters 1 and 2, you get my drift. How far can you go and still read the text? Maybe you can scramble your next e-mail that way, it would make it harder for the government to read it.

Make a Molecular Weight calculator. The user enters for instance the formula for salt NaCl and the program looks up the atomic weight of sodium and chlorine and adds them up.

A dictionary with element:weight pairs would make it easy. You also have to design some kind of parser that figures out molecules like water H2O. Here you have to add up hydrogen twice and oxygen once.

Things get a little more challenging for the parser with toluene, since the user could enter C7H8 or C6H5CH3. Elements like silicon Si have to be entered that way and not as SI, since your parser would look at it as a combination of sulfur S and iodine I.

Since the right data is already there, you can expand the program to do elemental analysis, giving the percent of each element in the formula. Happy coding!

Write a biorhythm program in Python. You have to input the birthday and present day, and then calculate the physical, emotional and intellectual values.

For more details on biorhythms see:
http://en.wikipedia.org/wiki/Biorhythm

How about a program to calculate the phase of the moon. I have seen a C program to do this, Python should be a lot easier, once you know the formula. Google for the formula, do a console version or embellish with some graphics if you want to. Both Tkinter and wxPython allow you to draw on a canvas.

commented: sweet idea +10

Make a crayon drawing or coloring program for the younger relatives. Python and Tkinter should have all the things you need. I know I have seen a doodle program somewhere, that could be the start.

A note from vegaseat: The wxPython docs and demo download has a doodle program you can build upon.

Some people are indubitably spooked by a Friday falling on the 13th of the month. Write a program to list all the Friday the 13th of a given year.

(Hint: look at modules datetime and calendar)

Write a hex-dump program, where you read a file byte by byte and display the value as a hexadecimal number (base 16). Display about 16 bytes on each row and in a second column next to it show any printable characters, useful for text.

Write a Python function that creates a box outlined by stars/asterisks (*). The function should display a box of x stars width and y stars height.

The next step would be to put some text into the box maintaining the star outline.

The ultimate function should take a text string and auto-outline it with the star box.

``````*****************
*               *
* Happy coding! *
*               *
*****************``````

Take a list of words like:

``list1 = ['Herring', 'used', 'to', 'be', 'abundant', 'in', 'the', 'Atlantic', 'Ocean', 'then', 'herring', 'got', 'overfished']``

and sort the list to show something like:

``['Atlantic', 'Herring', 'Ocean', 'abundant', ... ]``

Now sort the list case insensitive, so it looks more like:

``['abundant', 'Atlantic', 'be', 'got', ... ]``

Reverse this sorted list.

Sort the list by the lenght of the word, shortest word first.

Make the words in the list unique, note that Herring and herring are considered the same word.

Just a Python brain teaser, have fun!

A small project, but practical. Let's say you have a string of all the abbreviated months of the year:

``str1 = "JanFebMarAprMayJunJulAugSepOctNovDec"``

How can you extract the abbreviated month from that string given the number of the month (eg. 8 = "Aug")?

A later thought, how could you convert the above string to a list like ...

``['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']``

In other words, split the string at the capital letters.

Hyper Text Markup Language (HTML) is the backbone of a typical web page. Here is a very simple example:

``````<HTML>
<HEAD>
<TITLE>Link Lesson 1: Link Text</TITLE>
</HEAD>
<BODY>
The <A HREF="http://www.google.com">The Google Site</A> can be used to search
a large number of things, including  your favorite edible rhizome.
</BODY>
</HTML>``````

Write a Python function that extracts the url "http://www.google.com" from the HTML code. In other words, extract a substring from a text that is between two given substrings, here "=" and ">".

Write a program that gives a list of 100 unique random integers in the range of 0 to 999.

Make financial calculator that would show you monthly payments on a loan, or how long you would take to pay off your debts with certain monthly payments, or how many years it would take for your savings to double.

There are quite a number of songs out there with fairly repetitive lyrics. The "99 bottles of beer on the wall" song is an example, or this cute little example of a lyrics writer for the "old McDonald had a farm" song:

``````# print the lyrics of the song "Old McDonald had a farm"
# using functions to reduce your work

def print_exclamation():
print 'Ee ai ee ai oh!'

def print_refrain():
print 'Old McDonald had a farm.'
print_exclamation()

def print_song(animal, sound):
print_refrain()
print 'And on his farm he had a ' + animal + '.'
print_exclamation()
print 'With a ' + 2 * (sound + ' ') + 'here,'
print 'And a ' + 2 * (sound + ' ') + 'there.'
print 'Here a ' + sound + ', there a ' + sound + '.'
print 'Everywhere a ' + sound + ' ' + sound + '.'
print_refrain()

print_song('cow', 'moo') # test it with the cow that sounds moo``````

Sit down with the kids and see what other songs you could pythonize!

Here is an interesting project, the name game song ...

The name game!
Shirley!
Shirley Shirley Bo Birley
Banana Fanna Fo Firley
Fe Fi Mo Mirley
Shirley

Lincoln!
Lincoln Lincoln Bo Bincoln
Banana Fanna Fo Fincoln
Fe Fi Mo Mincoln
Lincoln

Come on everybody
I say now let's play a game
I betcha I could make a rhyme
Out of anybody's name

The first letter of the name
I treat it like it wasn't there
But a B or an F
Or an M will appear

And then I say Bo, add a B
Then I say the name
Then Banana Fanna and a Fo
Then I say the name again with an F very plain
Then a Fe Fi and a Mo
Then I say the name again with an M this time
And there isn't any name that I can't rhyme

Arnold!
Arnold Arnold Bo Barnold
Banana Fanna Fo Farnold
Fe Fi Mo Marnold
Arnold

But if the first two letters are ever the same,
Drop them both then say the name
Like Bob Bob drop the B's Bo Ob
Or Fred Fred drop the F's Fo Red
Or Mary Mary drop the M's Mo Ary
That's the only rule that is contrary

Okay?
Now say Bo (Bo!)
Now Tony with a B (Bony!)
Then Banana Fanna and Fo (Banana Fanna Fo!)
Then you say the name again with an F very plain (Fony!)
Then a Fe Fi and a Mo (Fe Fi Mo)
Then you say the name again with an M this time (Mony!)
And there isn't any name that you can't rhyme

Everybody do Tony
Tony Tony Bo Bony
Banana Fanna Fo Fony
Fe Fi Mo Mony
Tony

Pretty good. Let's do Billy
Billy Billy Bo Illy
Banana Fanna Fo Filly
Fe Fi Mo Milly
Billy

Very good. Let's do Marsha
Marsha Marsha Bo Barsha
Banana Fanna Fo Farsha
Fe Fi Mo Arsha
Marsha

A little trick with Nick
Nick Nick Bo Bick
Banana Fanna Fo Fick
Fe Fi Mo Mick
Nick

The name game!

Do at least the ...

Tony Tony Bo Bony
Banana Fanna Fo Fony
Fe Fi Mo Mony
Tony

... part of the lyrics with other names in Python. The rules are in the song!

In the USA yo have the following currency options:
100 Dollars
50 Dollars
20 Dollars
10 Dollars
5 Dollars
1 Dollar ( the 2 Dollar bill is very rare, ignore it)
25 cents ( the 50 cent coin is rare, also ignore it)
10 cents
5 cents
1 cent

Let's say a customer has a charge of \$161.13 and pays with two 100 Dollar bills. Write a Python program to figure out how to pay the customer his change with the least amount of currency items.

The code below shows a simple Tkinter GUI calculation template, that has two labeled input fields, a button to trigger the calculation and a label to show the result ...

``````# example of two labeled entries, button and result label
# uses grid to position widgets also sets focus/cursor
# a rather generic Tkinter GUI template for calculations

from Tkinter import *

def calculate():
try:
# get the enter1 and enter2 values
num1 = float(enter1.get())
num2 = float(enter2.get())
# do the calculation
result = num1 * num2
# display the result string
label3.config(text=str(result))
except ValueError:
label3.config(text='Enter numeric values!')

root = Tk()
#root.config(bg='yellow')

# first entry with label
label1 = Label(root, text='Enter a number:')
label1.grid(row=0, column=0)
enter1 = Entry(root, bg='yellow')
enter1.grid(row=1, column=0)

# second entry with label
label2 = Label(root, text='Enter another number:')
label2.grid(row=2, column=0)
enter2 = Entry(root, bg='yellow')
enter2.grid(row=3, column=0)

# do the calculation by clicking the button
btn1 = Button(root, text='Multiply Numbers', command=calculate)
btn1.grid(row=4, column=0)

# display the result in this label
label3 = Label(root)
label3.grid(row=5, column=0)

# start cursor in enter1
enter1.focus()
# value has been entered in enter1 now switch focus to enter2
enter1.bind('<Return>', func=lambda e:enter2.focus_set())

root.mainloop()``````

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

You can use this template with slight modifications to do all sorts of scientific and financial calculations. You can also add more labeled Entry widgets to create a GUI based mortgage calculator. Dream up something useful or playful!

Print a 9x9 diamond shaped pattern like this

``````*
***
*****
*******
*********
*******
*****
***
*``````

using loops.

Simply drawing a number of geometric lines, curves or shapes on a canvas can create a fairly good looking piece of art. Of course, your art teacher might disagree, but you are a better judge anyway!

You can size, locate and color your drawing objects at random, or in a predetermined progression using a mathematical formula driven by a loop or recursive function. It's amazing what comes out of those experimentations.

Take a look at the fractal tree snippet at:
http://www.daniweb.com/code/snippet510.html

Some colorful random drawings:
http://www.daniweb.com/code/snippet384.html

Write a program that goes through a given directory and writes a log file containing all the filenames, modification times and filesizes. Then on a later date, the program will check this log file to detect any changes in the directory of modification dates, file sizes, new files and deleted files. It will let the user know of any changes.

Imagine robot arm with three pulse driven motors. One motor for each axis (x = left/right, y = up/down, z = depth). Positive pulse goes 1/10 unit (cm or inch) in one direction, negative pulse in opposite direction.

At the end of the robot arm is woodcutting tool (router). Write Python program to make the tool cut one semisphere from solid block of wood (20x20x10 units).

Write a program to show all the files in a given drive that have been modified in the last 24 hours.

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.