0
Help with programming for school Iām new to python Write a program that will ask the user to enter the amount of a purchase.
The program should then compute the state sales tax and the county sales tax. Assume the state sales tax is 5 percent and the county sales tax is 2.5 percent. The program should display the amount of the purchase, that state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of the purchase plus the total sales tax). Hint: Use the value of 0.025 to represent 2.5 percent, and 0.05 to represent 5 percent. Please help
4 Answers
+ 4
Okay Aqua (Amir Battle) ,
the issue in your current code is the way the indentation is built.
> indentation starts with some unicodec characters 160, which is seen as an illegal character.
> if you replace this by regular space, the code will run. also check any `empty` lines.
> no other changes need to be done.
+ 3
Your attempt?
+ 2
Okay Aqua (Amir Battle) ,
There is no use of calling function..
So remove it and your code is working...
Look at this:-
https://code.sololearn.com/cHKv21W1N9x8/?ref=app
0
def main():
Ā Ā Ā # Constants for tax rates
Ā Ā Ā state_tax_rate = 0.05
Ā Ā Ā county_tax_rate = 0.025
Ā
Ā Ā Ā # Get the amount of the purchase from the user
Ā Ā Ā purchase_amount = float(input("Enter the amount of the purchase: "))
Ā
Ā Ā Ā # Calculate state and county sales tax
Ā Ā Ā state_sales_tax = purchase_amount * state_tax_rate
Ā Ā Ā county_sales_tax = purchase_amount * county_tax_rate
Ā
Ā Ā Ā # Calculate total sales tax and total sale amount
Ā Ā Ā total_sales_tax = state_sales_tax + county_sales_tax
Ā Ā Ā total_sale_amount = purchase_amount + total_sales_tax
Ā
Ā Ā Ā # Display the results
Ā Ā Ā print(f"Purchase amount: ${purchase_amount:.2f}")
Ā Ā Ā print(f"State sales tax: ${state_sales_tax:.2f}")
Ā Ā Ā print(f"County sales tax: ${county_sales_tax:.2f}")
Ā Ā Ā print(f"Total sales tax: ${total_sales_tax:.2f}")
Ā Ā Ā print(f"Total sale amount: ${total_sale_amount:.2f}")
Ā
# Call the main function
main()