$23.99
Purpose: Welcome to Homework 1. This homework introduces some of the basic tasks you'll need to do in future homework assignments, namely creating and running Python 3 Scripts (programs), testing your Python code, defining and using Python functions in your programs, naming functions and variables in your Python code file carefully, and submitting your HW problems using Moodle.
This is not a collaborative assignment; you must design, implement and test the solution(s) on your own. You may not consult or discuss the solution with anyone other than the course instructor or TAs. In addition, you may not include solutions or portions of solutions obtained from any source other than those provided in class, Moodle, or this assignment (i.e, do not refer to any internet sources other than those specified in the assignment, in lab, lecture, or available on the class Moodle site – so you can refer to the sources listed in the document named: Links to Credible Python Resources on the Internet).
Obtaining or sharing solutions to any homework problems for this class is considered academic misconduct. If you are not sure what this means, consult the class syllabus or discuss it with the course instructor.
The total point value for programming assignments will be awarded for solutions that are complete, correct, and well-constructed. A "well-constructed" program entails good design, appropriate comments and general readability (descriptive names for variables and procedures, appropriate use of blank space, etc.). The following will result in a score reduction equal to a percentage of the total possible points:
● Incorrectly named source file (100%)
● Constraints not followed (up to 100%)
● Failure to execute due to syntax errors (75%)
Note that your work will be graded using, and must function correctly with, the current version of Python
3 on the CSE Labs Ubuntu (Linux) machines. If you complete your programming assignment using a different system, it is your responsibility to ensure your programs work on CSE Labs machines prior to
submitting them.
This assignment is 5 pages long and consists of three Homework problems worth a total of 30 points
(each problem is worth 10 points).
Problem A: Computing the Simple Interest on a Loan (10 points)
Using appropriate UNIX commands and a text editor (such as Atom, Geany, IDLE, or something you are comfortable using), create a Python 3 script (program) to compute simple interest. We will go over (or went over) a similar Python 3 program (script) in class. The formula for computing the simple interest due on a loan is:
I = PRT, where:
I is the total amount of interest due after T years,
P is the Principal (amount of the loan),
R is the yearly interest rate (percent of the principal due in interest per year),
T is the amount of time (in years) that the borrower will require to pay back the loan.
Constraints:
Here is what one example run of your program should look like (user input is in Bold font):
Welcome to the Simple Interest Calculator! Enter the loan amount: 5000
Enter the interest rate: 7
Enter the time to repay loan (in years): 5
Interest is: 1750.00
1. The values entered by the user for P, R, and T should be stored as decimal numbers, so make sure to cast them to floating point numbers when obtaining them via the input function.
2. Note that an interest rate of 7% is entered as “7”, not as “0.07”. Also note that though the user enters
“7” as the interest rate, the value R = 0.07 is used in the formula I = PRT.
3. The output from your program should be the same as the format displayed in the example above, and the interest value should be rounded to two decimal places. Your program should yield the same answer as the example above when you input the same values specified in the example above.
4. Test your program with many different combinations of input values in addition to the one provided in the example above. You can assume that the input values will be positive and the number of years T will be at least 1.
5. Add a comment of the following type to the very beginning of file:
# CSci 1133 HW 1
# Your name
# HW Problem 1A
(where you replace “Your name” with your actual name).
3. When you are done, name the source code file <username_1A.py. Here you replace
<username with your U of M email address; for example, if your email address is smithx1234@umn.edu, your file should be named smithx1234_1A.py. Then submit your program using the HW 1 Problem A submission link in Moodle.
It is important that you follow the file naming conventions very carefully to receive credit for this and future assignments.
For example, note that your username should be in all lowercase, you should not include “@umn.edu”, the filename should contain an underscore (not a dash), the ‘A’ in the “1A” part is upper case, the ‘1’ is a one, not the letter ‘l’, the extension is .py, etc. Following rigorous naming conventions is something computer programmers often must do in “real life” programming, and so submitting your program with the correct name is part of doing this assignment correctly.
Problem B: Computing the interest earned on an investment earning compound interest (10 points)
Using appropriate UNIX commands and an editor, create and a Python 3 script (program) that computes the interest earned on an investment that is earning compound interest. The formula for computing the total amount an investment that earns compound interest yields is:
, where:
= Total amount the investment is worth at the end of the term is the Principal (initial investment amount)
is the interest rate
= number of times per year the interest is compounded
is the duration of time (in years) that the investment will remain untouched (no amount, other than the compound interest, will be added or withdrawn from the investment during time )
Constraints:
Below are what two example runs of your program should look like (user input is in Bold font):
Welcome to the Program to compute compound interest on an investment! Enter the initial investment amount: 5000
Enter the interest rate: 3.1
Enter number of times per year interest is compounded: 1
Enter length of time the money will be invested (in years): 5
Interest earned is: 824.56
========= RESTART: C:/Users/dchal/Desktop/1133/admin/Homework/CI.py
=========
Welcome to the Program to compute compound interest on an investment!
Enter the initial investment amount: 5000
Enter the interest rate: 3.1
Enter number of times per year interest is compounded: 4
Enter length of time the money will be invested (in years): 5
Interest earned is: 834.80
1. The computed value for interest earned printed by your program should be in the same format as illustrated in the examples above (two digits after the decimal point). Your program should yield the same answers as the examples above when you input the same values given in the examples above.
2. Test your program with many different input value combinations in addition to those provided in the examples above. You can assume the input values will be positive numbers, and both and will be at least 1.
3. Add a comment of the following type to the very beginning of file:
# CSci 1133 HW 1
# Your name
# HW Problem 1B
(where you replace “Your name” with your actual name).
3. When you are done, name the source code file <username_1B.py. Here you replace
<username with your U of M email address; for example, if your email address is smithx1234@umn.edu, your file should be named smithx1234_1B.py. Then submit your program using the HW 1 Problem B submission link in Moodle.
NOTE:
As with Problem A, the results are real number values (numbers with a decimal point, not integers).
It is important that you follow the file naming conventions very carefully to receive credit for this and future assignments.
For example, note your username should be in all lowercase, you should not include “@umn.edu”, the filename should contain an underscore (not a dash), the ‘B’ in the “1B” part is upper case, the ‘1’ is a one, not the letter ‘l’, the extension is .py, etc. Following rigorous naming conventions is something computer programmers often must do in “real life” programming, and so submitting your program with
the correct name is part of doing this assignment correctly.
Problem C: Defining and using a function as part of a Python 3 program to compute the Rule of 72. Use the appropriate UNIX commands and a text editor to create and save a file containing a Python 3
script (program) that defines and calls a function named RuleOf72. The function RuleOf72 should
accept one parameter named R, where R is a decimal-valued interest rate. The function will return a decimal value T, where T is the time (in years) required to double an investment at R percent compounded annually.
The formula for computing the Rule of 72 is:
T = 72 / R
Constraints
Here is what one example run of the program should look like (user input is in Bold font): Welcome to the Rule of 72 Calculator!
Enter interest rate: 7
Your investment will require 10.29 years to double
1. Your program should print out its answers in the same format as the example above (2 digits after the decimal place). Your program should yield the same answer as the example above when you input the same value given in the example above.
2. Test your program with many different input values in addition to the one provided in the example above. You can assume the input value for R will always be a positive real number.
3. Your Python 3 script (program) should define and use a PURE function named RuleOf72. The RuleOf72 function will accept a parameter named R and then compute and return the value T using the expression on the right-hand side of the formula specified above.
4. Add a comment of the following type to the very beginning of file:
# CSci 1133 HW 1
# Your name
# HW Problem 1C
(where you replace “Your name” with your actual name).
4. When you are done, name the source code file <username_1C.py. Here you replace
<username with your U of M email address; for example, if your email address is smithx1234@umn.edu, your file should be named smithx1234_1C.py. Then submit your program using the HW 1 Problem C submission link in Moodle.
It is important that you follow the file naming conventions very carefully to receive credit for this and future assignments.
For example, note your username should be in all lowercase, you should not include “@umn.edu”, the filename should contain an underscore (not a dash), the ‘C’ in the “1C” part is upper case, the ‘1’ is a one, not the letter ‘l’, the extension is .py, etc. Following rigorous naming conventions is something computer programmers often must do in “real life” programming, and so submitting your program with
the correct name is part of doing this assignment correctly.
Make sure you submit something before or by the submission deadline – you will get points for attempting to formulate a solution. Some points are better than no points!