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

22nd Aug 2023, 7:17 PM
Okay Aqua (Amir Battle)
4 ответов
+ 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.
24th Aug 2023, 6:23 PM
Lothar
Lothar - avatar
+ 3
Your attempt?
22nd Aug 2023, 7:18 PM
KrOW
KrOW - avatar
+ 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
22nd Aug 2023, 8:15 PM
Riya
Riya - avatar
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()
22nd Aug 2023, 7:25 PM
Okay Aqua (Amir Battle)