Assignment 1

Goals

The goal of this assignment is to get acquainted with Python using Jupyter Notebooks.

Instructions

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.9 for your work. 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 is the easiest way to install and manage Python. If you work locally, you may launch Jupyter Lab either from the Navigator application or via the command-line as jupyter-lab.

Due Date

The assignment is due at 11:59pm on Wednesday, February 2.

Submission

You should submit the completed notebook file required for this assignment on Blackboard. The filename of the notebook should be a1.ipynb.

Details

Please make sure to follow instructions to receive full credit. Use a markdown cell to Label each part of the assignment with the number of the section you are completing. You may put the code for each part into one or more cells.

0. Name & Z-ID (5 pts)

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.

1. Hello, DeKalb (5 pts)

Write code that prints “Hello, DeKalb” but split into two lines like the following

Hello,
DeKalb

2. Hello, <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.

3. Calculating Annuities (20 pts)

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 start with \(C\) dollars, 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 invest per period in order to have \(C\) dollars after \(n\) periods at a rate of \(i\). \(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. 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 (e.g. \(C = 2000\), \(i = .04\), \(n = 10\)) by changing their values and rerunning the formula cells.

3a. Future value of an ordinary annuity (5 pts)

\[ FVordinary(C, i, n) = C \times\ \left[\frac{(1+i)^n - 1)}{i}\right] \]

3b. Present value of an ordinary annuity (5 pts)

\[ PVordinary(C, i, n) = C \times\ \left[\frac{1-(1+i)^{-n}}{i}\right] \]

3c. Future value of an annuity due (5 pts)

\[ FVdue(C, i, n) = C \times\ \left[\frac{(1+i)^n - 1)}{i}\right] \times (1+i)] \]

3d. Present value of an annuity due (5 pts)

\[ PVdue(C, i, n) = C \times\ \left[\frac{1-(1+i)^{-n}}{i}\right] \times (1+i) \]

Hints
  • You can do the last two parts very efficiently using the principle of “don’t repeat yourself”!