1,105,332 Community Members

Projects for the Beginner

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
18
 

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on a project you are interested in. Maybe an image viewer, a slide show, computer generated random or fractal art, a database for your baseball cards, a story writer, ...

This sticky is dedicated to a list of just such projects.

If you know a good project, please post it here. If you have questions, start your own thread and don't clutter the sticky. Please do not post your answeres in here!

There is also a thread Advanced and Intermediate Projects , see:
http://www.daniweb.com/forums/thread257510.html

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
11
 

Start a code library. As time goes on you will collect code snippets, hints and tricks from all over the net. So why not use Python to store these cut and pasted pieces of code in a file.

Attach a title and a set of keywords to each snippet that allows you to search the file and retrieve the code easily. You might want to use just one file and keep appending, so you have to find a way to keep the snippets appart from each other within the file. I have done it with a list where the items were separated by a dotcode-marker, works well, but it may not be a good way.

You can search the file directly or load the file into a list to speed things up. I leave it up to you. Keep thinking!

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
5
 

A units of measurement converter. Think about all the things that are measured, like distance, area, volume, energy, weight, temperature, pressure and so on. Now think about the many units of measurement the people around the globe use, anything from rods, stones, pounds, inches, pints and liters. A rather long list.

Start simple, let's say just the distances and a few units. Get that to work, then add more. Google the net for conversion factors. How would you handle the information? Maybe a dictionary in Python. Are there any neat shortcuts?

Your program should answer questions like:
"How many inches in a meter?"
"How many milliliters in a pint?"
"How many acres in a square-mile?"
"How many pounds in a metric ton?"
"How many calories in a BTU?"

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
6
 

Construct a sentence generator. Write down a bunch of sentences. Now pick them apart into lists of nouns, verbs, adverbs, adjectives and so forth. Use these pieces and create new sentences more or less at random. Some of those will be silly, some utter nonsense, but some could be the start of poetry or a novel.

Just to get you started, here is a very simple sentence generator, that takes the three parts (subject, action, object) of a standard sentence, shuffles these parts and reassembles the sentence ...

# goofy sentence generator
 
import random
 
def make_sentence(part1, part2, part3, n=1):
    """return n random sentences"""
    # convert to lists
    p1 = part1.split('\n')
    p2 = part2.split('\n')
    p3 = part3.split('\n')
    # shuffle the lists
    random.shuffle(p1)
    random.shuffle(p2)
    random.shuffle(p3)
    # concatinate the sentences
    sentence = []
    for k in range(n):
        try:
            s = p1[k] + ' ' + p2[k] + ' ' + p3[k]
            s = s.capitalize() + '.'
            sentence.append(s)
        except IndexError:
            break
    return sentence
 
# break a typical sentence into 3 parts
# first part of a sentence (subject)
part1 = """\
a drunken sailor
a giggling goose
the yearning youth
the obese ostrich
this mean mouse
the skinny sister"""
 
# middle part of a sentence (action)
part2 = """\
jumps over
flies over
runs across
openly ogles
twice tastes
vomits on"""
 
# ending part of a sentence (object)
part3 = """\
a rusty fence
the laughing cow
the weedcovered backyard
the timid trucker
the rancid old cheese
the jolly jelly"""
 
print '-'*60
 
sentence = make_sentence(part1, part2, part3, 3)
for item in sentence:
    print item
print '-'*60
 
"""
a typical result -->
A drunken sailor flies over the laughing cow.
The obese ostrich runs across the weedcovered backyard.
This mean mouse openly ogles the jolly jelly.
"""

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

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
2
 

Why not a story teller? This is for the people that like writing stories. Ask the reader for a preference and the story starts in that direction. After a while ask for another preference and branch off along that preference.

The story evolves as directed by the reader. Great for adventure, mystery, romance and detective stories. Try it out on a short and simple story first. Who knows, it could be the next bestseller.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
4
 

Computer art can be fun. PyGame might be the way to go here. Start out by drawing geometric designs using circles, ovals, lines, rectangles, lots of colors, put them in a loop that changes location, dimensions and colors.

To get an idea, look at the Python snippet at:
http://www.daniweb.com/code/snippet384.html
You need to be able to freeze the graphics and save it as an image file.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
4
 

Make a physics problem solver. Sometimes called an equation solver.

Let's say you have a simple kinematics question:
Bertha jogs at an average 7 miles/hour, and her typical path is 2.5 miles long. How long will it take her.

You would let the user enter three items:
1. 7 miles/hour
2. 2.5 miles
3. ? hours
Your program should figure out the formula and fill the question mark.

A more advanced version would convert units and standardize them. So the user can enter:
1. 7 miles/hour
2. 17 minutes
3. ? feet

Once you get the hang of it, you can go from simple kinematics to dynamics, force, work, gravitation, magnetic flux, thermodynamics, quantum mechanics or to relativity.

Back in the dark ages when I took physics, I wrote one of these in a then brand-new language called C.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
4
 

How would you write a simple spell checker for a text file?

Start simple and test your code. Attached is full English spelling dictionary file, one word on a line.

Attachments DictionaryE.zip (286.9KB)
Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
1
 

Translate from one language to another. For instance from English to Texan.

Hint, one approach would be the one used in the Python code snippet at:
http://www.daniweb.com/code/snippet395.html

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
4
 

You just wrote a loop allowing the input of 20 names into a list. Alas, you made an error as you entered name number 17. Redesign your input loop, so you can correct the error easily without having to retype the previous 16 names.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
2
 

If you have a computer running Windows XP, then you can let the computer read text to you. For more details look at the Python snippet at:
http://www.daniweb.com/code/snippet326.html

You may load in a textfile and have it read, or simply read the results of a program out loud. You could help elderly people with failing eyesight, just keep thinking about uses.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
6
 

Create a Video Poker game. You can use PyGame, Tkinter or wxPython to bring up the cards.

Attached is a graphics file containing all the cards and a few decks.

Attachments Cards.zip (44.19KB)
Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
2
 

Create a quiz game. Bring up a question and give four possible answers to pick from. Load the question and answers from a data file that also includes the code for the correct answer. Ask the questions in random order, and bring them up only once during the quiz. This can be a console program or dressed up in a GUI. Keep track of the correct answers given and evaluate the contestant at the end.

Attached is a typical data file. The lines are in the following order:
Correct answer's code letter
Question
Answer A
Answer B
Answer C
Answer D
...

The data file is a nice mix of questions with some humor thrown in. Double check the order, I might have goofed it up.

Attachments QUIZ.zip (5.97KB)
Member Avatar
a1eio
Junior Poster
140 posts since Aug 2005
Reputation Points: 16 [?]
Q&As Helped to Solve: 32 [?]
Skill Endorsements: 0 [?]
 
3
 

I program for a hobby, not a job (yet)
so i have a severe hunger for ideas, this thread is great and i would like to contribute,
Here are some ideas that might give someone in my situation something to do:

This is an extract from a song by pink floyd, in my opinion (and my friend who pointed it out to me) it looks like an algorithm (set of instructions) Doesn't take long but it's interesting to see how other people do it. Simple terms:
Turn this into code

All movement is accomplished in six stages,
and the seventh brings return.
The seven is the number of the young light.
It forms when darkness is increased by one.
Change return success.
Going and coming without error.
Action brings good fortune...
Sunset.

P.S You may say there's no point, it depends on how you look at it...

Member Avatar
a1eio
Junior Poster
140 posts since Aug 2005
Reputation Points: 16 [?]
Q&As Helped to Solve: 32 [?]
Skill Endorsements: 0 [?]
 
1
 

How about this:

Make a program that can generate random passwords
For example:

password length is fixed (or the user could enter a length)
number of characters in password is random (or again the user could specify)
number of digits in password is random (or user specified)
location of numbers/characters in password is random OR you could ask the user for a word then you could use that as a base and perhaps stick things on the end or begining or perhaps replace certain letters with numbers.

All up to you, it's just an idea

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
3
 

The game of chess was invented a few hundred years ago in India. The story has it, that the ruler of the area was so enchanted with the game, that he called the inventor to his palace, and asked him to name a gift.

The seemingly humble man asked the ruler to put a grain of rice on the first square of the chessboard, two grains of rice on the second and so on, doubling the grains each time until all 64 squares of the chessboard were filled.

The ruler was thinking about a full sack of rice and happily agreed. I didn't count it myself, but there are 32,000,000 grains of rice in a short ton (2,000 lbs). So do the calculation in Python and make a modern day comparison. Assume that a 50 foot rail car can carry 50 tons of rice.

How long would the train have be to carry the inventor's request?

Member Avatar
bumsfeld
Posting Virtuoso
1,537 posts since Jul 2005
Reputation Points: 399 [?]
Q&As Helped to Solve: 261 [?]
Skill Endorsements: 7 [?]
 
2
 

Build a Memory Game. You shortly flash up a number of random words. Lets say three or five, and then ask the player to recall the words from a mutli choice answer. Do that a ten or twenty times and then rate the player.

They could be numbers too, but I think words are more fun.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
1
 

Create a "one word at a time" text reader. Display the word in a large font for a certain amount of time. Set the font size so even grandma can read it. The time the word is displayed could be adjustable and might depend on the length of the word.

Sounds like a GUI program. If you have questions about setting font sizes, ask in the forum.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
1
 

This project is similar to the "one word at a time" reader, except it functions like a flash card program. You display, let's say, a Spanish word for a certain amount of time and then the corresponding English word. What better to use than a Python dictionary? Then you can just read off the key followed by the value. This can be done as a simple console or a fancy shmenzy GUI program.

I hope the foreign characters display well. Otherwise you might have to stay with something more domestic.

Member Avatar
a1eio
Junior Poster
140 posts since Aug 2005
Reputation Points: 16 [?]
Q&As Helped to Solve: 32 [?]
Skill Endorsements: 0 [?]
 
0
 

How about this for something to do:

If you don't know what a ceaser cypher is then read this: http://library.thinkquest.org/C0126342/ceaser.htm

Make a simple program that encrypts and decrypts a simple sring into a ciphertext (my terminology is terrible, so bear with me)
example:

let's encrypt the string: 'ceaser'
using a ceaser shift of lets say...11
so to start with, the 'c' in ceaser would be shifted 11 places down the alphabet and end up as 'n':

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
     ^ --------- 11 -------- ^

so basically you do that untill all the letters in the plaintext 'ceaser'
have been shifted 11 places along the alphabet:
'ceaser' == 'npldpc'

Note: if you reach the end of the alphabet and the count (11) is still not finished just go back to the start, ('s' and 'r' had to do that)

So once you've got that nailed, let the user input the string they want to convert and perhaps let them change the shift (number of places the letter is moved)
then simple enough if you want to decode/decrypt (whatever it's called) just stick a minus in front of the shift number (11 would = -11) so that it shifts backwards, simple as that ey?
hehehe have fun, and remember to be careful because symbols like: ,.'/"# ect are not in the alphabet so you might want to filter those out somehow.
Remember, it's your code...so do what you want with it.

happy coding,
a1eio

You
Post:
Start New Discussion
View similar articles that have also been tagged: