943,960 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 173380
  • Python RSS
You are currently viewing page 18 of this multi-page discussion thread; Jump to the first page
Oct 31st, 2008
1

Re: Projects for the Beginner

Click to Expand / Collapse  Quote originally posted by XxAaronxX ...
Hi,
This is the first Python code i have written without the aid of a tutorial, i was wondering if you could look over it and provide me with your feed back on any bad habits i may have and if there was an easier way to write this, Your feedback would be greatly appreciated.

Thanks

import time
print "Welcome to my measurement converter"
print "This converter will convert meters into yards"

Meters = int(raw_input("Enter the number of meters"))
Yards = Meters * 1.094
print Meters, "Meters is equal to", Yards, "yards"

time.sleep(5)

Why don't you post it in a new thread so that we don't muddy up the tutorial thread with random comments.

Editor: Thanks, this post has been moved to its own thread.
Last edited by vegaseat; Dec 19th, 2008 at 12:03 pm.
Reputation Points: 31
Solved Threads: 7
Light Poster
tyincali is offline Offline
45 posts
since Oct 2008
Oct 31st, 2008
0

Re: Projects for the Beginner

Python is very well suited for text modifications. Write a small Python program that modifes this typical raw email text:
Python Syntax (Toggle Plain Text)
  1. Why did the chicken cross the road?
  2. >
  3. >
  4. > BARACK OBAMA:
  5. >> The chicken crossed the road because it was time for a
  6. > CHANGE! The chicken wanted CHANGE!
  7. >
  8. >
  9. > JOHN McCAIN:
  10. >> My friends, that chicken crossed the road because he
  11. > recognized the need to engage in cooperation and dialogue
  12. > with all the chickens on the other side of the road.
  13. >
  14. >
  15. > HILLARY CLINTON:
  16. > When I was First Lady, I personally helped that little
  17. > chicken to cross the road. This experience makes me
  18. > uniquely qualified to ensure -- right from Day One! -- that
  19. > every chicken in this country gets the chance it deserves to
  20. > cross the road. But then, this really isn't about me....
  21. >
  22. >
  23. > GEORGE W. BUSH:
  24. > We don't really care why the chicken crossed the road.
  25. > We just want to know if the chicken is on our side of the
  26. > road or not. The chicken is either against us or for us.
  27. > There is no middle ground here.
  28. >
  29. >
  30. > COLIN POWELL:
  31. > Now to the left of the screen, you can clearly see the
  32. > satellite image of the chicken crossing the road...
  33. >
  34. >
  35. > JOHN KERRY:
  36. > Although I voted to let the chicken cross the road, I am
  37. > now against it! It was the wrong road to cross, and I was
  38. > misled about the chicken's intentions. I am not for it
  39. > now, and will remain against it.
  40. >
  41. >
  42. > BILL CLINTON:
  43. > I did not cross that road with THAT chicken!!!! .... What,
  44. > exactly, is your definition of chicken?
  45. >
  46. >
  47. > AL GORE:
  48. > I invented the chicken!
  49. >
  50. >
  51. > DICK CHENEY:
  52. > Where's my gun?
  53. >
  54. >
  55. > ANDERSON COOPER:
  56. > We have reason to believe there is a chicken, but we have
  57. > not yet been allowed to have access to the other side of the
  58. > road.
  59. >
  60. >
  61. > PAT BUCHANAN:
  62. > To steal the job of a decent, hard-working American.
  63. >
  64. >
  65. > BARBARA WALTERS:
  66. > Isn't that interesting? In a few moments, we will be
  67. > listening to the chicken tell, for the first time, the
  68. > heart-warming story of how it experienced a serious case of
  69. > molting, and went on to accomplish its life long dream of
  70. > crossing the road.
  71. >
  72. >
  73. > OPRAH WINFREY:
  74. > Well, I understand that the chicken is having problems,
  75. > which is why he wants to cross this road so bad. So instead
  76. > of having the chicken learn from his mistakes and take
  77. > falls, which is a part of life, I'm going to give this
  78. > chicken a car so that he can just drive across the road and
  79. > not live his life like the rest of the chickens.
  80. >
  81. >
  82. > DR. PHIL:
  83. > The problem we have here is that this chicken won't
  84. > realize that he must first deal with the problem on
  85. > 'THIS' side of the road before it goes after the
  86. > problem on the 'OTHER SIDE' of the road. What we
  87. > need to do is help him realize how stupid he's acting by
  88. > not taking on his 'CURRENT' problems before adding
  89. > 'NEW' problems.
  90. >
  91. >
  92. > MARTHA STEWART:
  93. > No one called me to warn me which way that chicken was
  94. > going. I had a standing order at the Farmer's Market to
  95. > sell my eggs when the price dropped to a certain level. No
  96. > little bird gave me any insider information.
  97. >
  98. >
  99. > NANCY GRACE:
  100. > That chicken crossed the road because he's GUILTY! You
  101. > can see it in his eyes and the way he walks.
  102. >
  103. >
  104. > BILL GATES:
  105. > I have just released eChicken2008, which will not only
  106. > cross roads, but will lay eggs, file your important
  107. > documents, and balance your check book. Internet Explorer is
  108. > an integral pa rt of eChicken. This new platform is much
  109. > more stable and will never crash.
  110. >
  111. >
  112. > GRANDPA:
  113. > In my day, we didn't ask why the chicken crossed the
  114. > road. Somebody told us the chicken crossed the road, and
  115. > that was good enough.
  116. >
  117. >
  118. > DR. SEUSS:
  119. > Did the chicken cross the road? Did he cross it with a
  120. > toad? Yes, the chicken crossed the road, but why it crossed
  121. > I've not been told.
  122. >
  123. >
  124. > ERNEST HEMINGWAY:
  125. > To die in the rain. Alone.
  126. >
  127. >
  128. > ARISTOTLE:
  129. > It is the nature of chickens to cross the road.
  130. >
  131. >
  132. > JOHN LENNON:
  133. > Imagine all the chickens in the world crossing roads
  134. > together, in peace.
  135. >
  136. >
  137. > ALBERT EINSTEIN:
  138. > Did the chicken really cross the road, or did the road move
  139. > beneath the chicken?
  140. >
  141. >
  142. > COLONEL SANDERS:
  143. > Did I miss one?
To a more normal text like this:
Python Syntax (Toggle Plain Text)
  1. Why did the chicken cross the road?
  2.  
  3. Barack Obama:
  4. The chicken crossed the road because it was time for a
  5. CHANGE! The chicken wanted CHANGE!
  6.  
  7. John McCain:
  8. My friends, that chicken crossed the road because he
  9. recognized the need to engage in cooperation and dialogue
  10. with all the chickens on the other side of the road.
  11.  
  12. Hillary Clinton:
  13. When I was First Lady, I personally helped that little
  14. chicken to cross the road. This experience makes me
  15. uniquely qualified to ensure -- right from Day One! -- that
  16. every chicken in this country gets the chance it deserves to
  17. cross the road. But then, this really isn't about me....
  18.  
  19. George W. Bush:
  20. We don't really care why the chicken crossed the road.
  21. We just want to know if the chicken is on our side of the
  22. road or not. The chicken is either against us or for us.
  23. There is no middle ground here.
  24.  
  25. Colin Powell:
  26. Now to the left of the screen, you can clearly see the
  27. satellite image of the chicken crossing the road...
  28.  
  29. John Kerry:
  30. Although I voted to let the chicken cross the road, I am
  31. now against it! It was the wrong road to cross, and I was
  32. misled about the chicken's intentions. I am not for it
  33. now, and will remain against it.
  34.  
  35. Bill Clinton:
  36. I did not cross that road with THAT chicken!!!! .... What,
  37. exactly, is your definition of chicken?
  38.  
  39. Al Gore:
  40. I invented the chicken!
  41.  
  42. Dick Cheney:
  43. Where's my gun?
  44.  
  45. Anderson Cooper:
  46. We have reason to believe there is a chicken, but we have
  47. not yet been allowed to have access to the other side of the
  48. road.
  49.  
  50. Pat Buchanan:
  51. To steal the job of a decent, hard-working American.
  52.  
  53. Barbara Walters:
  54. Isn't that interesting? In a few moments, we will be
  55. listening to the chicken tell, for the first time, the
  56. heart-warming story of how it experienced a serious case of
  57. molting, and went on to accomplish its life long dream of
  58. crossing the road.
  59.  
  60. Oprah Winfrey:
  61. Well, I understand that the chicken is having problems,
  62. which is why he wants to cross this road so bad. So instead
  63. of having the chicken learn from his mistakes and take
  64. falls, which is a part of life, I'm going to give this
  65. chicken a car so that he can just drive across the road and
  66. not live his life like the rest of the chickens.
  67.  
  68. Dr. Phil:
  69. The problem we have here is that this chicken won't
  70. realize that he must first deal with the problem on
  71. 'THIS' side of the road before it goes after the
  72. problem on the 'OTHER SIDE' of the road. What we
  73. need to do is help him realize how stupid he's acting by
  74. not taking on his 'CURRENT' problems before adding
  75. 'NEW' problems.
  76.  
  77. Martha Stewart:
  78. No one called me to warn me which way that chicken was
  79. going. I had a standing order at the Farmer's Market to
  80. sell my eggs when the price dropped to a certain level. No
  81. little bird gave me any insider information.
  82.  
  83. Nancy Grace:
  84. That chicken crossed the road because he's GUILTY! You
  85. can see it in his eyes and the way he walks.
  86.  
  87. Bill Gates:
  88. I have just released eChicken2008, which will not only
  89. cross roads, but will lay eggs, file your important
  90. documents, and balance your check book. Internet Explorer is
  91. an integral pa rt of eChicken. This new platform is much
  92. more stable and will never crash.
  93.  
  94. Grandpa:
  95. In my day, we didn't ask why the chicken crossed the
  96. road. Somebody told us the chicken crossed the road, and
  97. that was good enough.
  98.  
  99. Dr. Seuss:
  100. Did the chicken cross the road? Did he cross it with a
  101. toad? Yes, the chicken crossed the road, but why it crossed
  102. I've not been told.
  103.  
  104. Ernest Hemingway:
  105. To die in the rain. Alone.
  106.  
  107. Aristotle:
  108. It is the nature of chickens to cross the road.
  109.  
  110. John Lennon:
  111. Imagine all the chickens in the world crossing roads
  112. together, in peace.
  113.  
  114. Albert Einstein:
  115. Did the chicken really cross the road, or did the road move
  116. beneath the chicken?
  117.  
  118. Colonel Sanders:
  119. Did I miss one?
Notice that something like JOHN McCAIN: --> John McCain: needs special attention.
Last edited by vegaseat; Apr 22nd, 2011 at 11:53 am. Reason: OP's request
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Nov 2nd, 2008
2

Re: Projects for the Beginner

You pay 2 Dollars and you are allowed to throw 4 dice. If the sum of the dice is less than 9, you win 12 Dollars, otherwise you lose your investment. Should you play this game?

Let a small Python program help you.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Nov 4th, 2008
0

Re: Projects for the Beginner

How about making a program that will get your weather forecast for tomorrow?

You can use modules such as urllib2 and things like that to get the source code of your favourite web weather forecaster and then scrape off all of the html tags to leave you with your forecast for the next few days.
Last edited by Paul Thompson; Nov 4th, 2008 at 4:38 pm.
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Nov 15th, 2008
1

Re: Projects for the Beginner

Let's have some fun with mathematics, write a Python program for each question:

1) What do you get when you add up the numbers 1-100 consecutively?

2) What number multiplied by itself gives the number 12345678987654321?

3) What five digit number, when multiplied by the number 4, gives a number with the digits in reverse order?
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Dec 20th, 2008
0

Re: Projects for the Beginner

Write a simple calendar program. One that will remember dates that you have set. For this you would have to save it in some place.
Perhaps take a look at Pickle modules. This can be used to save instances and the like.

This program could be used very well in a GUI in fact wxPython has a specific built in object for making a calendar...
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Dec 21st, 2008
0

Re: Projects for the Beginner

Python30 has been released, install it and go through much of the existing sample Python code and rewrite it so it will work on Python30.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Dec 26th, 2008
0

Re: Projects for the Beginner

Write a programmer's calculator that shows a numeric integer entry in denary (base10), binary(base2), octal(base8) and hexadecimal (base16). Allow entry in any of these bases.

Also does some simple binary stuff like shift-left and shift-right, binary or, binary and and binary xor.

If the integer falls into the ASCII range, display its character or meaning.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Dec 26th, 2008
0

Re: Projects for the Beginner

Write a program that gets that latest comic from your favourite webcomic.
For this you could use urllib to download the images.
Last edited by Paul Thompson; Dec 26th, 2008 at 3:35 pm.
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Dec 31st, 2008
0

Re: Projects for the Beginner

Write a program that goes through a list or folder of your favorite MP3 music files and playes it in the background.
Reputation Points: 625
Solved Threads: 211
Posting Virtuoso
Ene Uran is offline Offline
1,704 posts
since Aug 2005
Message:
Previous Thread in Python Forum Timeline: For loop, for creating buttons
Next Thread in Python Forum Timeline: How to execute a command with arguments





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC