| | |
Projects for the Beginner
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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:
Sit down with the kids and see what other songs you could pythonize!
python Syntax (Toggle Plain Text)
# 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
Last edited by vegaseat; Mar 1st, 2007 at 4:21 pm. Reason: [code=python] tag
May 'the Google' be with you!
Here is an interesting project, the name game song ...
Do at least the ...
... part of the lyrics with other names in Python. The rules are in the 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!
•
•
•
•
Tony Tony Bo Bony
Banana Fanna Fo Fony
Fe Fi Mo Mony
Tony
May 'the Google' be with you!
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.
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.
drink her pretty
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 ...
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!
python Syntax (Toggle Plain Text)
# 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()
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!
Last edited by vegaseat; Mar 1st, 2007 at 4:23 pm. Reason: [code=python] tag and comment
May 'the Google' be with you!
Print a 9x9 diamond shaped pattern like this
using loops.
Python Syntax (Toggle Plain Text)
* *** ***** ******* ********* ******* ***** *** *
Last edited by Ene Uran; Jun 19th, 2006 at 10:52 am.
drink her pretty
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
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
Last edited by vegaseat; Jun 25th, 2006 at 3:44 pm.
May 'the Google' be with you!
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.
May 'the Google' be with you!
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).
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).
Last edited by bumsfeld; Jul 2nd, 2006 at 11:42 am.
![]() |
Similar Threads
- Ideal project for a beginner? (Python)
- Hep finding C++ Projects (Python)
- Help finding C++ Projects (C++)
- New task from Projects for the beginner: (Python)
Other Threads in the Python Forum
- Previous Thread: Calling Function?
- Next Thread: How to avoid python shebang line on linux.
Views: 101927 | Replies: 209
| Thread Tools | Search this Thread |
Tag cloud for beginner, projects, python
.so abrupt address advice anti apax asp.net avogadro backend beginner bluetooth c++ calculator calling client code college compile coordinates curved def development django editing event examples excel file forms ftp function google gui http images input itunes j2seprojects java javaprojects launcher leak library linux list lists loop microsoft mouse movingimageswithpygame mysql newb newbie number opensource output php prime print programming projects push py2exe pygame pyglet pyqt python random recursive remote return ruby rubyconf silverlight slicenotation socket softwaredevelopment source string sum suthar syntax table tennis text threading tkinter tlapse tooltip tutorial ubuntu url urllib urllib2 variable webdevelopemnt wikipedia wordgame wxpython xlwt







