Help with some python homework...
David Hutto
dwightdhutto at gmail.com
Sun Feb 2 14:21:44 EST 2014
Should have been the following, which just shows the books price as a float as well, but you get the point by now, I'm sure:
import random as r
def order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * percent_discount_amount
amount_of_first_book = 1 # of course it would equal 1
discounted_price = price_per_book - percent_discount
shipping = first_book_shipping + ((quantity - amount_of_first_book) * extra_book_shipping)
total_price = (quantity * discounted_price) + shipping
print "Book XYZ-%d-ABC \nPrice per book: $%f\nPercent discount amount: %f\nQuantity of books: %f\nFirst book's shipping: $%f\nextra_book_shipping: $%f\nTotal price: $%f\n" % (books,price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping,total_price)
if __name__ == '__main__':
for books in range(0,10):
price_per_book = float(r.randint(1,100))
percent_discount_amount = float(".%d" % r.randint(0,100))
quantity = float(r.randint(0,100))
first_book_shipping = float(r.randint(0,100))
extra_book_shipping = float(r.randint(0,100))
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping)
More information about the Python-list
mailing list