DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   I need help please (http://www.daniweb.com/forums/thread174266.html)

ryn670489 Feb 8th, 2009 2:34 am
I need help please
 
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()

evstevemd Feb 8th, 2009 3:04 am
Re: I need help please
 
Use code tags to preserve pythonic look and catalyse rate of answering your question

ryn670489 Feb 8th, 2009 3:21 am
Re: I need help please
 
[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()

ryn670489 Feb 8th, 2009 3:22 am
Re: I need help please
 
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()]

ryn670489 Feb 8th, 2009 3:23 am
Re: I need help please
 
you cant edit your post or i just cant find it

evstevemd Feb 8th, 2009 3:58 am
Re: I need help please
 
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

Paul Thompson Feb 8th, 2009 5:27 am
Re: I need help please
 
Here we go:
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()

Paul Thompson Feb 8th, 2009 5:30 am
Re: I need help please
 
Okay here is a version with a lot of things fixed:
def main():
    books = getBooks()  #Remember those () otherwise the functions are not called
    points = getPoints(books) #again
    printPoints(books, points)

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) #Remeber to split up the string


main()

ryn670489 Feb 8th, 2009 10:31 am
Re: I need help please
 
thanks for your help paul


All times are GMT -4. The time now is 3:54 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC