我的代碼正在返回一個錯誤,它在= part上顯示「< = 80」。這是爲什麼?我該如何解決它?python語法錯誤30/09/2013
#Procedure to find number of books required
def number_books():
number_books = int(raw_input("Enter number of books you want to order: "))
price = float(15.99)
running_total = number_books * price
return number_books,price
#Procedure to work out discount
def discount(number_books):
if number_books >= 51 and <= 80:
discount = running_total/100 * 10
elif number_books >= 11 and <=50:
discount = running_total/100 * 7.5
elif number_books >= 6 and <=10:
discount = running_total/100 * 5
elif number_books >=1 and <=5:
discount = running_total/100 * 1
else print "Max number of books available to order is 80. Please re enter number: "
return discount
#Calculating final price
def calculation(running_total,discount):
final_price = running_total - discount
#Display results
def display(final_price)
print "Your order of", number_books, "copies of Computing science for beginners will cost £", final_price
#Main program
number_books()
discount(number_books)
calculation(running_total,discount)
display(final_price)
任何幫助,將不勝感激
請發佈完整的錯誤。 – thegrinner
@thegrinner:語法顯然是錯誤的,並且是一個常見的初學者錯誤。 –
@MartijnPieters我知道,我只是想讓OP習慣於發佈完整的錯誤,所以如果將來有更多的問題,它不會放慢速度。 – thegrinner