By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

How to make a program to calculate tax

P: 6
I'm trying to make a python program that

1) prompts the user to enter the value of the sale with the following statement:
“Enter the value of the company’s sales in dollars in August 2013:”

2)The sale value should be stored in a variable of type float

3)Compute the sales tax based on 6% of the sale

4) Print the resulting sales tax in the following format:
“The sales tax is $ for August 2013 ”

This is the code I currently have
Expand|Select|Wrap|Line Numbers
  1. salevalue = int(input("Enter the value of the company's sales in dollars in August 2013"))
  2.  
  3. saletax = float(salevalue*0.06)
  4.  
  5. print("The sales tax is" + saletax + "for August 2013")
I am very new to programming in python so I really have no idea where to go from here. Thanks for reading :)
Jan 26 '15 #1

✓ answered by bvdet

To print the result, you can use the format method.
Expand|Select|Wrap|Line Numbers
  1. >>> saletax = float(256753*0.06)
  2. >>> print("The sales tax is ${s:.2f} for August 2013".format(s=saletax))
  3. The sales tax is $15405.18 for August 2013
  4. >>> 

Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
To print the result, you can use the format method.
Expand|Select|Wrap|Line Numbers
  1. >>> saletax = float(256753*0.06)
  2. >>> print("The sales tax is ${s:.2f} for August 2013".format(s=saletax))
  3. The sales tax is $15405.18 for August 2013
  4. >>> 
Jan 26 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.