I need help please

Thread Solved

Join Date: Feb 2009
Posts: 5
Reputation: ryn670489 is an unknown quantity at this point 
Solved Threads: 0
ryn670489 ryn670489 is offline Offline
Newbie Poster

I need help please

 
0
  #1
Feb 8th, 2009
This is my code its to calculate book club points earned. i cant see where the error is if any one can help me i would be very gratefull. thank you

def main():
books = getBooks
points = getPoints
printPoints

def getBooks():
books = input("enter the books purchased")
return books

def getPoints(books):
if books <= 0:
points = 0
elif books <= 1:
points = 5
elif books <= 2:
points = 15
elif books <= 3:
points = 30
elif books <= 4:
points =60
return points

def printPoints(books,points):
print ("you bought ,books, you now have ,points,")


main()
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,320
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 124
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: I need help please

 
0
  #2
Feb 8th, 2009
Use code tags to preserve pythonic look and catalyse rate of answering your question
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 5
Reputation: ryn670489 is an unknown quantity at this point 
Solved Threads: 0
ryn670489 ryn670489 is offline Offline
Newbie Poster

Re: I need help please

 
0
  #3
Feb 8th, 2009
[code]
def main():
books = getBooks
points = getPoints
printPoints

def getBooks():
books = input("enter the books purchased")
return books

def getPoints(books):
if books <= 0:
points = 0
elif books <= 1:
points = 5
elif books <= 2:
points = 15
elif books <= 3:
points = 30
elif books <= 4:
points =60
return points

def printPoints(books,points):
print ("you bought ,books, you now have ,points,")


main()
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 5
Reputation: ryn670489 is an unknown quantity at this point 
Solved Threads: 0
ryn670489 ryn670489 is offline Offline
Newbie Poster

Re: I need help please

 
0
  #4
Feb 8th, 2009
script
[def main():
books = getBooks
points = getPoints
printPoints

def getBooks():
books = input("enter the books purchased")
return books

def getPoints(books):
if books <= 0:
points = 0
elif books <= 1:
points = 5
elif books <= 2:
points = 15
elif books <= 3:
points = 30
elif books <= 4:
points =60
return points

def printPoints(books,points):
print ("you bought ,books, you now have ,points,")


main()]
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 5
Reputation: ryn670489 is an unknown quantity at this point 
Solved Threads: 0
ryn670489 ryn670489 is offline Offline
Newbie Poster

Re: I need help please

 
0
  #5
Feb 8th, 2009
you cant edit your post or i just cant find it
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,320
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 124
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: I need help please

 
0
  #6
Feb 8th, 2009
Write "CODE=python" enclosed in square brackets then paste your code from your editor and end it with "/CODE" also in square brackets.
Note, all are without Quotes
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 893
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 142
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: I need help please

 
0
  #7
Feb 8th, 2009
Here we go:
  1. def main():
  2. books = getBooks
  3. points = getPoints
  4. printPoints
  5.  
  6. def getBooks():
  7. books = input("enter the books purchased")
  8. return books
  9.  
  10. def getPoints(books):
  11. if books <= 0:
  12. points = 0
  13. elif books <= 1:
  14. points = 5
  15. elif books <= 2:
  16. points = 15
  17. elif books <= 3:
  18. points = 30
  19. elif books <= 4:
  20. points =60
  21. return points
  22.  
  23. def printPoints(books,points):
  24. print ("you bought ,books, you now have ,points,")
  25.  
  26.  
  27. main()
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: May 2008
Posts: 893
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 142
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: I need help please

 
0
  #8
Feb 8th, 2009
Okay here is a version with a lot of things fixed:
  1. def main():
  2. books = getBooks() #Remember those () otherwise the functions are not called
  3. points = getPoints(books) #again
  4. printPoints(books, points)
  5.  
  6. def getBooks():
  7. books = input("enter the books purchased")
  8. return books
  9.  
  10. def getPoints(books):
  11. if books <= 0:
  12. points = 0
  13. elif books <= 1:
  14. points = 5
  15. elif books <= 2:
  16. points = 15
  17. elif books <= 3:
  18. points = 30
  19. elif books <= 4:
  20. points =60
  21. return points
  22.  
  23. def printPoints(books,points):
  24. print ("you bought" ,books, "you now have ",points) #Remeber to split up the string
  25.  
  26.  
  27. main()
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: Feb 2009
Posts: 5
Reputation: ryn670489 is an unknown quantity at this point 
Solved Threads: 0
ryn670489 ryn670489 is offline Offline
Newbie Poster

Re: I need help please

 
0
  #9
Feb 8th, 2009
thanks for your help paul
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC