[noob] Error!

Discussion in 'Python' started by administrata, Feb 4, 2005.

  1. administrata

    administrata Guest

    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... :)
    administrata, Feb 4, 2005
    #1
    1. Advertising

  2. administrata

    Jeff Shannon Guest

    administrata wrote:

    > 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
    Jeff Shannon, Feb 5, 2005
    #2
    1. Advertising

  3. 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
    Brian van den Broek, Feb 5, 2005
    #3
  4. administrata

    John Machin Guest

    Re: Error!

    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
    John Machin, Feb 5, 2005
    #4
  5. administrata

    administrata Guest

    Re: Error!

    "John Machin" <> wrote in message news:<>...
    > 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 :\

    can you modify actual_price?

    actual_price = (((base_price * tax / 100) + license1 / 100) + dealer +
    charge
    administrata, Feb 5, 2005
    #5
  6. administrata

    Steve Holden Guest

    Re: Error!

    administrata wrote:

    > "John Machin" <> wrote in message news:<>...
    >
    >>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/
    Steve Holden, Feb 5, 2005
    #6
  7. administrata

    Steve Holden Guest

    Re: Error!

    Bruno Desthuilliers wrote:

    > 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 ?


    Oops.

    Let's try

    tax_amount = base_price*(tax_rate/100.0)

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

    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/
    Steve Holden, Feb 5, 2005
    #7
  8. Re: Error!

    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 ?
    Bruno Desthuilliers, Feb 5, 2005
    #8
  9. administrata

    administrata Guest

    Re: Error!

    "John Machin" <> wrote in message news:<>...
    > 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


    Thx 4 helps everyone! :)
    administrata, Feb 6, 2005
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. We need more power captain
    Replies:
    3
    Views:
    6,701
    Muthu
    Feb 18, 2004
  2. lucifer

    Noob Java Error

    lucifer, Jun 8, 2007, in forum: Java
    Replies:
    1
    Views:
    495
    Andrew Thompson
    Jun 8, 2007
  3. Replies:
    2
    Views:
    257
    joseph cook
    Oct 8, 2008
  4. Replies:
    1
    Views:
    263
  5. Tom Willis
    Replies:
    1
    Views:
    85
    Tom Willis
    Mar 23, 2005
Loading...

Share This Page