RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 63392 | Replies: 175
Reply
Join Date: Oct 2004
Posts: 2,546
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Solution Re: Projects for the Beginner

  #21  
Sep 26th, 2005
Whenever Pythonians gather, there is always a call for an executable file.

If you have Dev-C++, embedding Python is quite easy with the free Python Development Pak. Look at this C++ code snippet for more information:
http://www.daniweb.com/code/snippet387.html

The Python code has to be fed in strings (morsels) to the embedded interpreter, which actually uses a DLL like Python24.dll. I have played around with it, and found for instance that the for loops etc. have to be in one string (interpretable morsel) with a '\n' after the colon and proper indentation included.

For the masochists, this might be one way to create an executable Python file. Come to think of it, you could let a Python program do the nasty detailed work here! You might call it a Python to C++ translator.

Could be fun to experiment with it, start small and grow.
May 'the Google' be with you!
Reply With Quote  
Join Date: Oct 2004
Posts: 2,546
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Solution Re: Projects for the Beginner

  #22  
Sep 30th, 2005
If you know a little about C++, take a look at this snippet:
http://www.daniweb.com/code/snippet97.html
It shows you how to access the soundchip on your Windows computer, and create all sorts of interesting sound effects. Will it be possible to do this with Python?
May 'the Google' be with you!
Reply With Quote  
Join Date: Jun 2005
Posts: 142
Reputation: G-Do is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 11
G-Do's Avatar
G-Do G-Do is offline Offline
Junior Poster

Re: Projects for the Beginner

  #23  
Oct 1st, 2005
Write a simple calculator in Python. The program should accept an arithmetic expression from the command-line, then recursively parse it to produce a numerical value.

Like many programming projects, this one can be done in phases:

i) First, make the program parse only basic arithmetic. This means expressions that use only numbers and {+-*/%} (the percent sign means "modulo" - look it up if you don't know what that means).

ii) Next add in left and right parentheses.

iii) Next add in logs, exponents, absolute values, roots, and powers.

iv) Next add in the ability to solve expressions in terms of an unknown variable x, like in algebra. This part will be tricky!

Having coded up one of these guys before, let me tell you: it's not trivial, and it will make you change the way you think about parsing text/expressions.

If you want, you can also write a Tkinter GUI, but the challenging part is writing the calculator itself.
Vi veri veniversum vivus vici
Reply With Quote  
Join Date: Jun 2005
Posts: 142
Reputation: G-Do is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 11
G-Do's Avatar
G-Do G-Do is offline Offline
Junior Poster

Re: Projects for the Beginner

  #24  
Oct 1st, 2005
Somewhere upthread, vegaseat wrote about a sentence generator. Well, here's a twist: how about a sentence detector? In other words, can you write a program that can tell the difference between a body of text written by a human being and a body of text put together at random by a computer program?

We know that certain words are very likely to appear next to each other in the English language. For example, "English language," "next to," "for example," etc. The idea of the program is this: use urllib2 to parse a whole bunch of text from the results of random Google searches. Build a frequency table of word pairs. In other words, for every page you download, scan every two adjacent words on the page, and if the pair is new, add it to the table with a score equal to one, and otherwise, increase the score of the current entry in the table by one. A dictionary is probably best suited for this kind of data storage.

Then take some unknown text and score it using the frequency table. Again, scan every two adjacent words. If the pair is in the table, add its score to a running sum. If the pair is not in the table, subtract some arbitrary amount from the running sum. If the final sum is above some threshold, the program should say "I think this was made by a human being," and otherwise, the program should say "I think this is randomly-generated text."

Tweak your program until it can usually recognize the difference between a page off the Internet and a randomly-generated page. Better yet, see if you can get it to recognize the difference between an English language page off the Internet and a translated page in a foreign language.

You can, of course, make simplifications to the program, such as not counting numbers and detagging HTML pages.
Vi veri veniversum vivus vici
Reply With Quote  
Join Date: Jun 2005
Posts: 142
Reputation: G-Do is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 11
G-Do's Avatar
G-Do G-Do is offline Offline
Junior Poster

Re: Projects for the Beginner

  #25  
Oct 1st, 2005
Write a simple Python shell with a GUI. The shell should use Python functions whenever possible to make it as portable as it can be. This is another project that can be divided into phases:

i) Write the shell GUI. It should have a spot to enter commands and a scrollable output screen.

ii) Write the command parser. Have the shell recognize a limited subset of commands. If it sees those commands, it does the appropriate thing in Python - otherwise, it hands the command to the OS and reproduces the output on its screen. The list of commands the program should recognize are: cd, ls, clear, echo, exit, pwd, touch, rm, mkdir, rmdir, mv, cp, chmod, and ps. Most of these can be written in Python, but some may have to be redirected to the OS.

iii) Add a command history feature, so that pressing the up and down arrow keys lets you cycle through previously entered commands.

iv) Add the ability to run a command in the background by adding an & to it.

v) Add the ability to redirect output using > and >>.

vi) If you're feeling particularly ambitious, try to add tab-completion.

vii) If you're feeling very, very ambitious, try to add pipes!

I tried to do this before, and got stuck on (iii). I figured out that (using Tkinter) I needed threads to monitor up/down arrow keypresses, and I didn't have the energy to deal with threading at the time.
Vi veri veniversum vivus vici
Reply With Quote  
Join Date: Oct 2004
Posts: 2,546
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Solution Re: Projects for the Beginner

  #26  
Oct 11th, 2005
Take a look at:
http://www.daniweb.com/code/snippet395.html

This Python code snippet shows you how to replace multiple words in a text with matches in a dictionary. You could create a dictionary of slang words and make interesting texts.
May 'the Google' be with you!
Reply With Quote  
Join Date: Jul 2005
Location: France
Posts: 1,051
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 46
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Veteran Poster

Solution Re: Projects for the Beginner

  #27  
Oct 16th, 2005
This project takes wxPython or maybe Tkinter for GUI. Let the computer pick random color selecting random RGB value. The user has to match the color picking RGB (red, green, blue) values that colours a area next to the one of the computer color pick.
Reply With Quote  
Join Date: Jul 2005
Location: France
Posts: 1,051
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 46
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Veteran Poster

Solution Re: Projects for the Beginner

  #28  
Oct 16th, 2005
Similar to the color project but with frequency of a tone. The computer plays a tone with random audible frequency. The user tries to match this frequency. In a GUI project can use a slider. Buttons allow replay of either tone. At end evaluate closeness.
Reply With Quote  
Join Date: Oct 2004
Posts: 2,546
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Solution Re: Projects for the Beginner

  #29  
Nov 21st, 2005
The code snippet called "Access Your PC Soundcard (Python)" at:
http://www.daniweb.com/code/snippet431.html
should give you the idea of how to select a musical instrument and play a short melody or a drum beat.

Write a quiz program that plays an instrument, and then let the user select from a multiple choice question which instrument was played.
May 'the Google' be with you!
Reply With Quote  
Join Date: Jul 2005
Location: France
Posts: 1,051
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 46
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Veteran Poster

Solution Re: Projects for the Beginner

  #30  
Nov 23rd, 2005
If you have five dice, how often do you have to throw (average) the dice to get a hand of four sixes? Try with other poker hands too.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:35 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC