*Using Python code Problem: You have been asked to write a program that will hel
ID: 3595533 • Letter: #
Question
*Using Python code
Problem: You have been asked to write a program that will help users estimate credit card payments and interest paid. Your program will ask the user to enter the yearly interest rate for the credit card as a percentage, then will repeatedly ask the user to reenter the rate when the user entered a yearly interest rate less than 1% or greater than 30%.
I can't seem to get my code to work perfectly. Towards the end the interest number is not rounded to 2 decimal places. Can someone help fix what I got so far?
*My code is below the sample inputs
There are some input samples given below.
Here is my code:
C:WINDOWSIsystem32lcmd. exe What is the yearly interest rate for the credit card entered as a percent? 12 The balance from the previous month was $0.00 There was $0.00 in interest applied to your account last month hat were the total charges for this month? 150 Your current balance is $150.00 The minimum payment for this month is $11.25 How much would you like to pay this month? 39 The balance from the previous month was $120.00 There was $1.20 in interest applied to your account last month What were the total charges for this month? 15 Your current balance is $136.20 The minimum payment for this month is $10.21 How much would you like to pay this month? 60 The balance from the previous month was $76.20 There was $0.76 in interest applied to your account last month What were the total charges for this month? Your current balance is $76.96 The minimum payment for this month is $10.00 How much would you like to pay this month? 40 The balance from the previous month was $36.96 There was $0.37 in interest applied to your account last month What were the total charges for this month? 18 Your current balance is $55.33 The minimum payment for this month is $10.00 How much would you like to pay this month? 50 The balance from the previous month was $5.33. There was $0.05 in interest applied to your account last month What were the total charges for this month? Your current balance is $5.38 The minimum payment for this month is $5.38 How much would you like to pay this month? 5.38 Your account has been paid off You paid a total of $2.38 in interest Press any keu to continueExplanation / Answer
Hi,
Your function is fine, instead of using %0.2f, you can use round(x,2) which rounds values to 2 decimal places,
other than that, code looks fine, change the formatting to round and you are done.
specifically use round(balance,2) instead of format(balance, '%.21f')
Thumbs up if this was helpful , otherwise let me know in comments
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.