Answered step by step
Verified Expert Solution
Question
1 Approved Answer
While using python I came across a problem that said. line 9, ValueError: could not convert string tk float: . How can I fix this
While using python I came across a problem that said. "line 9, ValueError: could not convert string tk float: ". How can I fix this problem so that when I run this code it doesn't run into this error anymore and works properly.
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL rate_value = float (rate[t-1]) / 100 ValueError: could not convert string to float: " (base) vanessaveVanessas-MacBook-Pro %/ opt/anaconda3/bin/python /Users/vanessav/Desktop/overdue_tax.py Enter amount of tax owed: 500 Enter interest rate: 5 Enter number of days overdue tax 1s: 365 Traceback (most recent call last): File "/Users/vanessav/Desktop/overdue_tax.py", Line 9 , in emodules rate_value = float (ratel:-1]) / 100 ValueError: could not convert string to float: " (base) vanessaveVanessas-MacBook-Pro % PENALTY_RATE =0.06 \#Do not chan tax = input ('Enter amount of tax owed: ') \#Do not change, will be in format $100 rate = input('Enter interest rate: ') \#Do not change, will be in format 4% late = int (input('Enter number of days overdue tax is: ')) \#Do not change, will penalty = PENALTY_RATE tax interest = rate [1:] late*EARTH_YEAR* ( tax + penalty ) total = tax + interest print ('Your total payment is' + total) The user (and our testing program) will enter the data in the following formats: tax owed will be a string that starts with a dollar sign, e.g., $10000 and interest rate will be a string that is a percentage with a percent sign, e.g. 5%. The days overdue will be entered as an integer. Here are some examples of program execution. Pay special attention to the formats of the inputs and outputs your printed output should match exactly in terms of spacing and text. The final value should be rounded off: Enter amount of tax owed: $500 Enter interest rate: 5% Enter number of days overdue tax is: 365 Your total payment is 555 Enter amount of tax owed: $500 Enter interest rate: 4% Enter number of days overdue tax is: 1095 Your total payment is 590 Enter amount of tax owed: $500 Enter interest rate: 4% Enter number of days overdue tax is: 250 Your total payment is 544 Your well-styled program should be submitted in a file called overdue_tax.py (the same name as the template file given to you). Your program should work for any inputs in the format shown - inputs representing numeric values will always be positive numbers, but keep in mind that tax owed may not be in exact dollar values (i.e. there may be cents like $15000.25 - the IRS usually rounds to the nearest dollar but we won't) and the interest percentage may not be a whole number and may have more than a single digit (e.g. 10.5\%). The number of days will always be input as a positive integer. N.B.: (1) you must only use programming structures discussed so far - this means no conditionals and no imported mathematical functions/modules and no object types that we have not discussed yet. You don't need them. (2) You are not permitted to edit the first five lines of code given in any way. Program Four: The Taxman If you fail to pay income tax in a timely manner and you owe the government (or the state you live in) money, you are subject both to a penalty and interest on the amount owed. Even if you are living on Mars, if you are a US citizen, you have to file Federal taxes. Suppose that during your stay-cation on Mars, the interstellar mail took too long and you haven't paid your taxes on time... your tax return was literally lost in space. You owe the original tax plus a penalty that is 6% of the tax amount - for our purposes the penalty will always be 6%. You also owe interest on the tax (not the penalty, just the tax). The amount of interest depends on the current yearly rate and the amount of interest you owe depends on how many days overdue the tax is. This is best shown by a few examples. Example 1: Tax owed: $500,365 days ( 1 year) overdue Penalty ( 6% of tax owed): $30 Interest rate: 5% yearly Interest owed ( 5% of tax owed): \$25 Total amount to pay: $555 Example 2: Tax owed: $500,1095 days ( 3 years) overdue Penalty ( 6% of tax owed): $30 Interest rate: 4% yearly Interest owed ( 4% of tax owed per year times 3 years): $60 Total amount to pay: $590 Example 3: Tax owed: $500,250 days overdue Penalty ( 6% of tax owed): $30 Interest rate: 4% yearly Interest owed ( 4% of tax owed per year times 250 days out of 365 ): approx.. $13.70 Total amount to pay: $544 In the file, overdue_tax.py, you have been given code for a program that provides constants for the length of a year and the penalty rate, and solicits the tax owed, the number of days overdue, and the interest rate from the user. The program is supposed to calculate the total amount owed, but the program is incorrect. Your job is to debug the program. Debugging the code means that you edit the lines in place. You should not add lines, delete lines, or move the order of lines. Correct the lines as they are and preserve as much of the original code as possible. HINT: figure out what each line is trying to accomplish first before making any changes Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started