Needs to be done in Python: A friend of yours has gotten the new “Rocket” credit
ID: 3785305 • Letter: N
Question
Needs to be done in Python:
A friend of yours has gotten the new “Rocket” credit card. Every dollar purchased gets you 1000 meters towards a free one-way trip to the planet Venus! To attract customers the card oers a novel interest rate. For each month in debt, the percentage owed in interest increases by a power of 2. For example, after 1 month, the interest owed is equal to 2% (21) of the original debt. After 2 months, the interest is 4% (22) of the original debt and so on.
In general: interest(m) = d * (2m/100)
Note: This formula is not a Python assignment statement! It is an equation that says that if you know the
quantitiesm(the number of months) and d (the original debt), you can calculate a value using the right side
of the equation, giving you a quantity that tells you the the total interest after m months.
Write a program which does the following:
Prompt the user to enter an initial amount of Rocket credit card debt. You must make sure that the user enters a positive number. If they do not enter a positive number, print a message informing them so, and prompt them to enter the initial amount of debt again. Keep doing this until they enter a positive
number.
Starting from month 1, print to the console the total payment owed at 1-month intervals. Thus, for month 1, month 2, etc., you should print out the total payment owing, which consists of the interest plus the original debt. Your program should stop after the rst month where the total payment owing is greater than 100 times the original debt (that’s the point at which the credit company calls in its debts, whether you like it or not!).
Don’t forget to import the math module if you need math functions.
Hint: A correct solution should make use of two separate while-loops.
This is what I have so far, im not sure how to go about doing the interest calculation:
Explanation / Answer
while True:
initial_debt = input("What is your initial debt? ")
try:
number = int(initial_debt)
if number < 0:
print("Please enter a positive number")
continue
except ValueError:
print("Please enter a number")
mon = 1
while True:
interest = (initial_debt*(2.0*mon))/(100.0)
print("The interest for month "+str(mon)+" is "+str(interest))
mon+=1
if(interest>=100*initial_debt):
break
break
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.