Error!

Steve Holden steve at holdenweb.com
Sat Feb 5 08:05:20 EST 2005


administrata wrote:

> "John Machin" <sjmachin at lexicon.net> wrote in message news:<1107563070.861085.180680 at g14g2000cwa.googlegroups.com>...
> 
>>administrata wrote:
>>
>>>I'm programming Car Salesman Program.
>>>It's been "3 days" learning python...
>>
>>>From whom or what book or what tutorial?
>>
>>
>>>But, i got problem
>>
>>You got problemS. What Jeff & Brian wrote, plus:
>>
>>You have "change" instead of "charge".
>>
>>You forgot to add in the base price -- "actual price" according to you
>>comprises only the taxes and fees. Where is your car yard? We'd each
>>like to order a nice shiny red Ferrari :-)
>>
>>Cheers,
>>John
> 
> 
> erm... sry i don't get it :\
> 
He's referring to the fact that your calculations, probably through 
inexperience with programming, don't appear to add tax to the base price 
but rather simply compute tax from it.

Don't worry, it wasn't *that* funny :-)

> can you modify actual_price?
> 
> actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
> charge

It would be much simpler if, having read the base price and the license 
(which I presume you are expecting to be percentages) you then 
separately computed the tax *amount* and the license *amount*, then just 
added everything together.

So, for example, your program might look like this:

base_price = int(raw_input(...))
tax_rate = int(raw_input(...)
tax_amount = base_price * ((100+tax_amount)/...)
  ...
actual_price = (base_price +
                 tax_amount +
                 license_amount +
                 dealer +
                 charge)
print "Please hand over", actual_price

Obviously the "..." are the bits you fill in to complete the program. 
Good luck!

regards
  Steve
-- 
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005                      http://www.pycon.org/
Steve Holden                           http://www.holdenweb.com/



More information about the Python-list mailing list