On Sat, Dec 12, 2015 at 01:03:05AM -0600, Jim Gallaher wrote: > Hi everyone. I'm reading through a beginners Python book and came up > with a super simple program. I'm not getting any errors and everything > runs through, but there's a logical calculation error. What the program > does is take an amount and calculate a couple percentages and add a > couple fees. > > For example, if I put in a value of 1, it will output 752.12 as the sub > total and 753.12 as the grand total. It's off by 1 on sub total and 2 on > grand total.
Check your arithmetic -- with a base price of $1, the sub total is $752.12 and the grand total is $753.12, exactly as Python calculates. But I wonder whether you have made a logic mistake in your code. You say: dealerPrep = basePrice + 500 destinationCharge = basePrice + 250 This means that the car will cost more than TRIPLE the base price. Instead of $1, enter a base price of $40,000 and you will see what I mean: now the dealer prep is $40500 and the destination charge is $40250, which added to the base price gives $120750 (plus tax and licence). Surely that's not right, the deal charges more than the cost of the car for preparation? I think what you want is: dealerPrep = 500 destinationCharge = 250 -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor