The goal of this assignment is to get acquainted with Python using Jupyter Notebooks.
You will be doing your work in a Jupyter notebook for this
assignment. You may choose to work on this assignment on a hosted
environment (e.g. tiger)
or on your own local installation of Jupyter and Python. You should use
Python 3.12 for your work. (Older versions may work, but your code will
be checked with Python 3.12.) To use tiger, use the credentials you
received. If you work remotely, make sure to download the .ipynb file to
turn in. If you choose to work locally, Anaconda or miniforge are
probably the easiest ways to install and manage Python. If you work
locally, you may launch Jupyter Lab either from the Navigator
application (anaconda) or via the command-line as
jupyter-lab
or jupyter lab
.
The assignment is due at 11:59pm on Friday, September 6.
You should submit the completed notebook file required for this
assignment on Blackboard. The
filename of the notebook should be a1.ipynb
.
Please make sure to follow instructions to receive full credit. Use a markdown cell to Label each part of the assignment with a heading that includes the number of the section you are completing. You may put the code for each part into one or more cells.
The first cell of your notebook should be a markdown cell with a line for your name and a line for your Z-ID. If you wish to add other information (the assignment name, a description of the assignment), you may do so after these two lines.
Write code that prints “Hello, DeKalb” but split into two lines like the following
Hello,
DeKalb
<name>
(5 pts)Write code that assigns your name (a string) to a variable, and then
prints Hello, <name>
where <name>
comes from the variable. Thus, if you change the string assigned to the
variable, the output should change.
(Explanation updated 2024-09-03; formulas are the same.) An annuity is a financial product where you add or subtract the same amount of money every period, e.g., month or year, and earn a consistent interest rate at the end of every period. In an ordinary annuity, the money is added at the end of each period. A bank account with direct deposit is an example of an ordinary annuity. In an annuity due, the money is added at the beginning of the period. Rent is an example of an annuity due. The future value of an annuity is the amount of money you will have if you add \(C\) dollars per period, earn an interest rate of \(i\), and keep it invested for \(n\) periods. The present value of an annuity is how much money you need to have in order to have \(C\) dollars per period for \(n\) periods at a rate of \(i\). Thus, \(C\) is the cash flow per period, \(i\) is the interest rate and \(n\) is the number of payments.
Write code that calculates the following four formulas related to
annuities. First, create a cell that assigns the values (\(C = 1000\), \(i =
.05\), \(n = 5\)) to the
variables c
, i
, and n
. Then,
write four cells (one for each part) to calculate the formulas below.
Look for ways to make your code efficient. Assign the
output to its corresponding variable (fv_ordinary
,
pv_ordinary
, fv_due
, and pv_due
)
and display the output of each formula’s calculation. Note that your
formulas must use the variables c
, i
,
and n
; this will allow you to also check other values of
those variables by changing their values and rerunning the formula
cells. For example, you might go back to the first cell that assigns the
values and change them to \(C = 2000\),
\(i = .04\), \(n = 10\), and then recompute the next four
cells. Turn in your code with the original values (\(C = 1000\), \(i =
.05\), \(n = 5\)).
\[ FVordinary(C, i, n) = C \times\ \left[\frac{(1+i)^n - 1}{i}\right] \]
\[ PVordinary(C, i, n) = C \times\ \left[\frac{1-(1+i)^{-n}}{i}\right] \]
\[ FVdue(C, i, n) = C \times\ \left[\frac{(1+i)^n - 1}{i}\right] \times (1+i) \]
\[ PVdue(C, i, n) = C \times\ \left[\frac{1-(1+i)^{-n}}{i}\right] \times (1+i) \]