Submission: FirstNameLastNameHomework1.py file

Start your script with the comment #FirstName LastName Homework1, save the file as FirstNameLastNameHomework1.py, and submit it to blackboard.

#Part A

- Copy this line of code as is, do not modify the line directly:

pagination = ‘Page 1 of 12’

- Find the substring ‘12’ in the
*pagination*variable from Step 1 using the*index()*function and save the result to a new variable. Name the new variable what you want.

- Cast the variable from step 2 to an int datatype and print the result.

Part A Example (if your code works correctly, this should be the result):

12

#Part B

Calculate the average and variance for 4 marathon runners. If you do not remember how to calculate variance, you can follow the example on this very simple website (do not confuse Standard Deviation with Variance).

- Copy this code as is:

runner1 = 300.25 #Finish time in Minutes

runner2 = 260.75

runner3 = 315.75

runner4 = 245.25

average = ????????????????????????????????

print(‘Average:’, average)

- Replace the question marks on line 5 of Step 1 with the appropriate equation to determine the average using the 4 runner variables.

- Add the following code:

variance = ????????????????????????????????

print(‘Variance:’, variance)

- Replace the question marks in the code from Step 3 with the appropriate equation to determine the variance.

Part B Example:

Average: 280.5

Variance: 816.3125

#Part C

Frequently in business, we want to calculate the future value of an investment or loan after interest has compounded. The equation to do this is:

A = P( 1 +r/n)nt

Where A is the future value,

P is the principal (initial amount invested or borrowed)

r is the annual rate of interest as a decimal

n is the number of times the interest rate compounds per year

t is the term of the loan or the number of years before it is repaid

We want to build a calculator that will:

- Ask the user to input the values for the variables above;

- Perform the calculation; and

- Print the following string to the user:

In [t] years, at the interest rate of [r] compounded [n] times per year, the initial amount of [P] will be worth [A]

Example:

In 5 years, at the interest rate of 5% compounded 4 times per year, the initial amount of $5000.00 will be worth $6410.19

Note that the figures in this string have been formatted to include only two decimals and a dollar symbol.

You can check the results of your script by using an online future value calculator, like this one. If you do so, leave the annual addition amount at 0 and select ‘start’ as the ‘Make additions at’ option.

Part C Example:

Please enter principle:

4000

Please enter annual interest rate (example 5.2 for 5.2%):

5.2

Please enter the term in years:

5

Please enter number of times the interest will compound per year:

365

In 5.0 years, at the interest rate of 5.2% compounded 365 times per year, the initial amount of $4,000.00 will be worth $5,187.62.

Extra challenge:

If this assignment was easy, you can also calculate the amount paid to interest and print it to a new line. Extra challenges are not necessary to receive full credit on homework and labs.

Extra Challenge Output example:

In 5.0 years, at the interest rate of 5.2% compounded 365 times per year, the initial amount of $4,000.00 will be worth $5,187.62.

$1,187.62 will be paid in interest.

## Order an Essay Now & Get These Features For Free:

Turnitin Report

Formatting

Title Page

Citation

Outline