[noob] Error!

A

administrata

I'm programming Car Salesman Program.
It's been "3 days" learning python...
But, i got problem


Write a Car Salesman program where the user enters the base price of a
car. The program should add on a bunch of extra fees such as tax,
license, dealer prep, and destination charge. Make tax and license a
percent of the base price. The other fees should be set values.
Display the actual price of the car once all the extras are applied.

print "CAR SALESMAN PROGRAM"
print "\nEnter data."
base_price = int(raw_input("Base Price: "))

tax = int(raw_input("/nTax: "))
license1 = int(raw_input("License: "))
dealer = 30
charge = 5
print "Dealer Prep: ", dealer
print "Destination Charge: ", charge

actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
change
print "\n\nActual price: ", actual_price

raw_input("")

error occurs, i think the problem is in actual_price. but,
I don't know how to comebine percentage and raw_input.
help me...

thx 4 reading... :)
 
J

Jeff Shannon

administrata said:
Write a Car Salesman program [...]

This sounds like homework, and we generally try to avoid solving
peoples' homework problems for them, but I can offer a suggestion.
error occurs, i think the problem is in actual_price. but,
I don't know how to comebine percentage and raw_input.
help me...

It's hard to be sure since you don't say what the error is, nor
anything about what you expect to see and what you actually see.

However, if you're pretty sure that the problem is the line where you
calculate actual_price, then fire up an interactive interpreter and
try fiddling with things. You've got a lot of subexpressions there;
pick some values and try each subexpression, one at a time, and take a
look at what you get.

I bet that it won't take you long to figure out why you're not getting
the result you expect.

Jeff Shannon
Technician/Programmer
Credit International
 
B

Brian van den Broek

administrata said unto the world upon 2005-02-04 17:59:
I'm programming Car Salesman Program.
It's been "3 days" learning python...
But, i got problem


Write a Car Salesman program where the user enters the base price of a
car. The program should add on a bunch of extra fees such as tax,
license, dealer prep, and destination charge. Make tax and license a
percent of the base price. The other fees should be set values.
Display the actual price of the car once all the extras are applied.
>
print "CAR SALESMAN PROGRAM"
print "\nEnter data."
base_price = int(raw_input("Base Price: "))

tax = int(raw_input("/nTax: "))
license1 = int(raw_input("License: "))
dealer = 30
charge = 5
print "Dealer Prep: ", dealer
print "Destination Charge: ", charge

actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
change
print "\n\nActual price: ", actual_price

raw_input("")

error occurs, i think the problem is in actual_price. but,
I don't know how to comebine percentage and raw_input.
help me...

thx 4 reading... :)

Hi,

a couple of general tips for seeking help:

1) "error occurs" isn't helpful. What's the error? How do you know? Is
it that you don't get the expected output? Then show what you get and
say what you expected. Is it that you get a traceback giving detailed
and helpful information to track down the error? Then include those
details in your post. (They might not make sense to you, but they will
help helpers help you.)

2) This smells like a homework problem. If it is, say so. That way, no
one will think you are trying to get someone to do your homework for
you, and will be much more receptive to request for a push in the
right direction.

Looking at the line:

actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
change

I see you've 3 '('s, but only 2 ')'s.

Also, because of point (1), I cannot know if this is relevant to your
sense that there is an error, but in:

(base_price * tax / 100)

you might try changing 100 to 100.0. Run these through the interpreter:
1 / 10
1 / 10.0
and consult the FAQ on www.python.org for an explanation of the
difference.

Best,

Brian vdB
 
J

John Machin

administrata said:
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
 
A

administrata

John Machin said:
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 :\

can you modify actual_price?

actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
charge
 
S

Steve Holden

administrata said:
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
 
S

Steve Holden

Bruno said:
Steve Holden a écrit :
(snip)


s/(100+tax_amount)/(100 + tax_rate)/, I guess ?

Oops.

Let's try

tax_amount = base_price*(tax_rate/100.0)

Clearly I was right about simplification being a good idea :)

regards
Steve
 
B

Bruno Desthuilliers

Steve Holden a écrit :
(snip)
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)/...)
s/(100+tax_amount)/(100 + tax_rate)/, I guess ?
 
A

administrata

John Machin said:
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

Thx 4 helps everyone! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top