For this assignment, you will need the information in:
Don't forget to execute the cells in the notebook, that I've written for you.
In what follows, you will see me using comments. Comments start with a hash character - #
. Python ignores everything after the hash character. This is useful to write text for you or others to read, inside your code.
# This is just a comment. Python ignores it. It's just for show.
Nothing happens - Python ignored everything after the hash character.
The problem is my bank.
I have a credit card debt of £500.
Let's give that debt amount, a name:
# This is the amount I owe at the moment
my_debt = 500
At the moment, the bank is nice enough to charge me 10% interest per year. Let's give that a name too.
interest_rate = 0.1
The amount of interest, after one year, is therefore:
interest = my_debt * interest_rate
interest
50.0
Then my total new debt will be:
my_debt + interest
550.0
I can also calculate my total new debt all in one go by multiplying by 1 + interest_rate
- in my case - 1.1
.
debt_increaser = 1 + interest_rate
debt_increaser
1.1
my_debt * debt_increaser
550.0
Add your code to the cell below, and execute it, to show my total debt after two years. Your code will probably start with:
my_debt * debt_increaser
# Show my debt after two years.
# Your code below this comment
Fill in the next cell, in the same way, to show my debt after three years.
# Show my debt after three years.
Now show my debt after 10 years. You might want to use the power operator **
to do this.
# Show my debt after ten years.
The bank has just sent me a nice letter explaining that they are going to start charging me interest every week instead of every year. They value me as a customer, so, instead of dividing the annual interest rate by 52, they are going to divide it by 53 instead. But - is that a good offer?
Here is their proposed weekly interest rate:
weekly_interest_rate = interest_rate / 53
weekly_interest_rate
0.0018867924528301887
That corresponds to:
weekly_debt_increaser = 1 + weekly_interest_rate
weekly_debt_increaser
1.0018867924528303
So, starting from my original debt, I will owe this much after one week:
# What I owe, after one week, on the new deal
my_debt * weekly_debt_increaser
500.94339622641513
Fill in the cell below, to show how much I will owe after 52 weeks. You will probably want **
here again.
# Show my debt after 52 weeks, on the new deal
Can you calculate roughly what the weekly interest rate has to be, in order to correspond to the 10% annual interest that I started with? There are several ways to do this, but you can try trial and error, if you like.
# Your code to estimate the right weekly interest rate.