Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:42:02+00:00 2026-05-26T14:42:02+00:00

I am learning python and I am challenging myself to write a little program

  • 0

I am learning python and I am challenging myself to write a little program that asks the user the base price of a car, then saves the base price to a variable called base. It has two other variables called tax and license that are percentages. So it gets the base price, gets seven (7) percent of the base price, and adds it to the base price. It does the same for the license fee, etc.

However, what I want to know is that when it runs:
print "\nAfter taxes the price is: ", (base * tax / 100 + base)
how can I save the result to another variable so that the next line I dont have to write:
print "\nAfter taxes and license fee the price is: ", (base*tax / 100)+(base*license /100) + base? Rewriting it feels very redundant and like I’m wasting time by calculation something that has already been calculated.

I want to save the result of the first print line to a variable called after_tax so that then I could write:
print "\nAfter taxes and license fee the price is: ", after_tax + (base*license /100)

(I want the first print command to also save the result of the math calculation to a variable called after_tax so that I can reuse the result without having to retype out the entire calculation to get the result again).

Below is the code in it’s entirety:

#Car salesman calculations program.

base = int(raw_input("What is the base price of the car?" + "\n"))
tax = 7

license = 4

dealer_prep = 500

destination_charge = 1000


print "\nAfter taxes the price is: ", (base * tax / 100 + base)

print "\nAfter taxes and license fee the price is: ", (base*tax / 100)+(base*license /100) + base

print "\nAfter taxes and license fee and dealer prep the price is: ", (base*tax / 100)+(base*license /100) + base + dealer_prep

print "\nAfter taxes, license fees, dealer prep, and destination charge, the total price is: ", (base*tax / 100)+(base*license /100) + base + dealer_prep + destination_charge

raw_input("\nPress the enter key to close the window.")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:42:02+00:00Added an answer on May 26, 2026 at 2:42 pm

    you could do all your calculations up front. i recommend giving the variables (a, b, c, etc) smarter names than I did here, but this is illustrative enough.

    a = (base * tax / 100)
    b = (base*license /100)
    c = a + b + base
    d = c + dealer_prep
    e = d + destination_charge
    
    print "\nAfter taxes the price is: ", a + base
    print "\nAfter taxes and license fee the price is: ", c
    print "\nAfter taxes and license fee and dealer prep the price is: ", d
    print "\nAfter taxes, license fees, dealer prep, and destination charge, the total price is: ", e
    
    raw_input("\nPress the enter key to close the window.")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning Python and writing a program that keeps track of the total number
I was learning python using the tutorial that comes with the standard python installation.
I am learning Python and PyGTK. I'm trying to write a Twitter client. Which
I'm learning python with a book that teaches by creating games. I have to
I'm learning Python and can't even write the first example: print 2 ** 100
I'm learning Python and for practicing purposes I'm writing a script that reads a
I am learning Python and I just read in a book that Python 3
I am learning Python for a class now, and we just covered tuples as
I've been learning python for a while now with some success. I even managed
I recently started learning Python and I was rather surprised to find a 1000

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.