Projects for the Beginner

Reply   View First Unread View First Unread

Join Date: Jan 2008
Posts: 666
Reputation: ZZucker is on a distinguished road 
Solved Threads: 38
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Practically a Master Poster

Re: Projects for the Beginner

 
0
  #141
Feb 9th, 2008
Here is an easy one. Create a list of integers between 1 an 100 that are not divisible by 2 or 3.
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,009
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 929
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Projects for the Beginner

 
0
  #142
Mar 14th, 2008
If you had a way to mark water molucules, and then added 1 drop of
that marked water into the earth's oceans and mixed it well. How many
of the marked molcules of water would you find in each drop of ocean water?

Some helpful information:
Avogadro's number N = 6.023 x 10^23 (6.023e23) molecules/mole
1 mole of water has a volume of 18 ml
Assume that 1 ml water contains 30 drops
Volume of all the earth's oceans is 1.35 billion cubic kilometers
Last edited by vegaseat; Mar 14th, 2008 at 8:58 pm.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,542
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 171
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: Projects for the Beginner

 
0
  #143
Mar 22nd, 2008
You are constructing a robot vehicle that has two tracks like a tank. Each track is driven by a DC motor that can go from full foreward (signal = 1.0) to slower foreward (eg. signal = 0.3) to rest (signal = 0.0) and slow reverse (eg. signal = -0.1) to full reverse (signal = -1.0). To turn, one track is moved slower than the other.

The control is done with a joy stick that has two variable outputs. One is the x-axis (full foreward 1.0 to full reverse -1.0) and y-axis (full left = 1.0 to full right -1.0). Write a Python program that interprets these outputs correctly so the two motors can receive the proper signal for variable speeds foreward, reverse, and left and right turns.
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,009
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 929
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Projects for the Beginner

 
0
  #144
Mar 23rd, 2008
Tomorrow is Easter Sunday, and it's quite early this year. Use the following Python function to calculate the earliest Easter Sunday for the next 100 years (2008 to 2108) and for the next 1000 years ...
  1. def calc_easter(year):
  2. """returns the date of Easter Sunday of the given yyyy year"""
  3. y = year
  4. # golden year - 1
  5. g = y % 19
  6. # offset
  7. e = 0
  8. # century
  9. c = y/100
  10. # h is (23 - Epact) mod 30
  11. h = (c-c/4-(8*c+13)/25+19*g+15)%30
  12. # number of days from March 21 to Paschal Full Moon
  13. i = h-(h/28)*(1-(h/28)*(29/(h+1))*((21-g)/11))
  14. # weekday for Paschal Full Moon (0=Sunday)
  15. j = (y+y/4+i+2-c+c/4)%7
  16. # number of days from March 21 to Sunday on or before Paschal Full Moon
  17. # p can be from -6 to 28
  18. p = i-j+e
  19. d = 1+(p+27+(p+6)/40)%31
  20. m = 3+(p+26)/30
  21. # returns (month, day, year) tuple of Easter Sunday
  22. return (m, d, y)
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 666
Reputation: ZZucker is on a distinguished road 
Solved Threads: 38
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Practically a Master Poster

Re: Projects for the Beginner

 
0
  #145
Mar 23rd, 2008
Here is a small dictionary of food items and their calories. The portion amounts vary all over the map. Convert all calories for a 1 oz portion or, if you desire, a 100 gram portion (1 oz = 28.35 grams):
  1. # a dictionary of {food_name:[amount, calories], ...}
  2. food = {
  3. "pastrami": ["2 oz", 170],
  4. "meatloaf": ["3 oz", 315],
  5. "veal": ["3.5 oz", 190],
  6. "beef": ["2 oz", 310],
  7. "venison": ["4 oz", 225],
  8. "potato": ["8 oz", 100],
  9. "spinach": ["8 oz", 45],
  10. "tomato": ["8 oz", 45],
  11. "egg plant": ["3.5 oz", 25],
  12. "cauliflower": ["8 oz", 35],
  13. "butter": ["1 oz", 200],
  14. "cheddar": ["1 oz", 115],
  15. "swiss": ["1 oz", 105],
  16. "egg": ["2 oz", 80]
  17. }
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 666
Reputation: ZZucker is on a distinguished road 
Solved Threads: 38
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Practically a Master Poster

Re: Projects for the Beginner

 
0
  #146
May 8th, 2008
Using the Tkinter or the wxPython GUI toolkit, design a program that uses sliders to change the RGB values of a sample label's background color and its text (foreground) color in real time. Once you are happy with the colors, allow it to save the rgb values to the clipboard so they can be used in a program.

This Python snippet might be of help:
http://www.daniweb.com/code/snippet457.html
Last edited by ZZucker; May 8th, 2008 at 5:23 pm. Reason: ref
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,542
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 171
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: Projects for the Beginner

 
0
  #147
May 18th, 2008
Here is a very basic text editor using the wxPython GUI toolkit. Your mission will be to add some features like find, replace, wordcount etc. to it:
  1. # the start of a small text editor with file load and save menu
  2. # notice that the wx.TextCtrl() surface has already some advanced
  3. # features:
  4. # you can select text, right click to cut, copy and paste etc.
  5.  
  6. import os
  7. import wx
  8.  
  9. # pick unique ID values
  10. ID_ABOUT = 101
  11. ID_LOAD = 102
  12. ID_SAVE = 103
  13. ID_EXIT = 110
  14.  
  15. class MyFrame(wx.Frame):
  16. def __init__(self, parent, id, title):
  17. wx.Frame.__init__(self, parent, wx.ID_ANY, title, size = (500, 300))
  18. self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
  19. # statusBar at the bottom of the window
  20. self.CreateStatusBar()
  21. # set up the menu
  22. filemenu= wx.Menu()
  23. filemenu.Append(ID_ABOUT, "&About"," Information about this program")
  24. filemenu.Append(ID_LOAD,"File&Load", " Load a text file")
  25. filemenu.Append(ID_SAVE,"File&Save", " Save a text file")
  26. filemenu.AppendSeparator()
  27. filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")
  28. # create the menubar
  29. menuBar = wx.MenuBar()
  30. # adding the "filemenu" to the MenuBar
  31. menuBar.Append(filemenu,"&File")
  32. # adding the MenuBar to the Frame content
  33. self.SetMenuBar(menuBar)
  34. # attach the menu-event ID_ABOUT to the method self.OnAbout
  35. wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
  36. # attach the menu-event ID_OPEN to the method self.OnOpen
  37. wx.EVT_MENU(self, ID_LOAD, self.OnLoad)
  38. # attach the menu-event ID_SAVE to the method self.OnSave
  39. wx.EVT_MENU(self, ID_SAVE, self.OnSave)
  40. # attach the menu-event ID_EXIT to the method self.OnExit
  41. wx.EVT_MENU(self, ID_EXIT, self.OnExit)
  42. # display the frame
  43. self.Show(True)
  44.  
  45. def OnAbout(self, e):
  46. """ the about box """
  47. about = wx.MessageDialog( self, " A very simple editor \n"
  48. " using the wxPython GUI toolkit", "About Simple Editor", wx.OK)
  49. about.ShowModal()
  50. about.Destroy()
  51.  
  52. def OnLoad(self, e):
  53. """ open a file"""
  54. self.dirname = ''
  55. dlg = wx.FileDialog(self, "Choose a file to load",
  56. self.dirname, "", "*.*", wx.OPEN)
  57. if dlg.ShowModal() == wx.ID_OK:
  58. self.filename = dlg.GetFilename()
  59. self.dirname = dlg.GetDirectory()
  60. f = open(os.path.join(self.dirname,self.filename),'r')
  61. self.control.SetValue(f.read())
  62. f.close()
  63. dlg.Destroy()
  64.  
  65. def OnSave(self, e):
  66. """ Save a file"""
  67. self.dirname = ''
  68. dlg = wx.FileDialog(self, "Choose or create a file to save to",
  69. self.dirname, "", "*.*", wx.SAVE)
  70. if dlg.ShowModal() == wx.ID_OK:
  71. self.filename = dlg.GetFilename()
  72. self.dirname = dlg.GetDirectory()
  73. f = open(os.path.join(self.dirname,self.filename),'w')
  74. f.write(self.control.GetValue())
  75. f.close()
  76. dlg.Destroy()
  77.  
  78. def OnExit(self, e):
  79. self.Close(True)
  80.  
  81.  
  82. app = wx.PySimpleApp()
  83. frame = MyFrame(None, -1, "A Simple Editor (click on File for menu)")
  84. app.MainLoop()
Last edited by vegaseat; Jul 31st, 2008 at 11:52 pm. Reason: error in OnSave
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 901
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Projects for the Beginner

 
0
  #148
May 25th, 2008
How about a Noughts and Crosses game with AI so when the computer can it will win and it will block the player from winning if it can.
Try make it so there are difficulty setting ranging from easy to beat to nearly impossible.
If you want you could add a tournament kind of thing by having 'best of three' rounds
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,521
Reputation: Lardmeister is an unknown quantity at this point 
Solved Threads: 22
Lardmeister's Avatar
Lardmeister Lardmeister is offline Offline
Posting Virtuoso

Re: Projects for the Beginner

 
0
  #149
May 26th, 2008
Some Python riddles. Try to figure out the possible results:
  1. print max(max('hello', 'world'))
  1. print [1] * 5
  1. q = zip(range(3), 'abc')
  2. t1, t2 = zip(*q)
  3. print q
  4. print t1
  5. print t2
I upped my sanitary measures, up yours!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 666
Reputation: ZZucker is on a distinguished road 
Solved Threads: 38
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Practically a Master Poster

Re: Projects for the Beginner

 
0
  #150
May 28th, 2008
The short Python program below shows you how to create a hot-spot on a frame/window surface using the Tkinter GUI toolkit:
  1. # show mouse position as mouse is moved and create a hot-spot
  2.  
  3. import Tkinter as tk
  4.  
  5. root = tk.Tk()
  6.  
  7. def showxy(event):
  8. xm = event.x
  9. ym = event.y
  10. str1 = "mouse at x=%d y=%d" % (xm, ym)
  11. root.title(str1)
  12. # switch color to red if mouse enters a set location range (hot-spot)
  13. x = 100
  14. y = 100
  15. delta = 10 # range around center x,y
  16. if abs(xm - x) < delta and abs(ym - y) < delta:
  17. frame.config(bg='red')
  18. else:
  19. frame.config(bg='yellow')
  20.  
  21.  
  22. frame = tk.Frame(root, bg= 'yellow', width=300, height=200)
  23. frame.bind("<Motion>", showxy)
  24. frame.pack()
  25.  
  26. root.mainloop()
Your project will be to put a picture or map image on the surface, and then create a number of hot-spots. When the mouse pointer gets in range of these hot-spots a descriptive text message could appear. You could also make it different sounds or whatever, use your imagination.
Last edited by ZZucker; May 28th, 2008 at 5:45 pm.
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote Quick reply to this message  
Reply

Tags
beginner, projects, python

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC