Added Homework 04 - Strings
This commit is contained in:
parent
aad4e226c5
commit
be356ccb59
24 changed files with 315 additions and 0 deletions
49
homework/homework04/results/autoloan01.py
Normal file
49
homework/homework04/results/autoloan01.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
'''
|
||||
Auto Loan Payment Calculations
|
||||
==============================
|
||||
|
||||
https://www.wikihow.com/Calculate-Auto-Loan-Payments
|
||||
Use the formula A = P ∗ ( r ( 1 + r ) n ) / ( ( 1 + r ) n − 1 )
|
||||
|
||||
A = the monthly payment.
|
||||
P = the principal
|
||||
r = the interest rate per month, which equals the annual interest rate divided by 12
|
||||
n = the total number of months
|
||||
|
||||
Mass Sales Tax
|
||||
==============
|
||||
|
||||
The .0625 (6.25%) sales tax is paid in the first year only.
|
||||
|
||||
https://www.mass.gov/guides/motor-vehicle-and-trailer-sales-and-use-tax
|
||||
|
||||
Mass Excise Tax Fees
|
||||
====================
|
||||
|
||||
The tax depends on the vehicle age. For this program we only calculate the
|
||||
excise tax on the first year of purchase.
|
||||
https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm
|
||||
|
||||
'''
|
||||
|
||||
# ======================= Input Variables ==================================
|
||||
principal = 15090.
|
||||
rate = .07
|
||||
numberOfYears = 4
|
||||
# ===========================================================================
|
||||
|
||||
rate = rate /100
|
||||
ratePerMonth = rate /12
|
||||
numberOfMonths = numberOfYears * 12
|
||||
salesTax = principal * .0625 # Mass sales tax rate
|
||||
# https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm
|
||||
exciseTax = principal / 1000 * .9 * 25.00
|
||||
|
||||
monthlyPayment = principal * (ratePerMonth * (1+ratePerMonth)**(numberOfMonths))/((1+ratePerMonth)**(numberOfMonths)-1)
|
||||
|
||||
print("The payment is ", monthlyPayment)
|
||||
print("The sales tax is ", salesTax)
|
||||
print("The excise tax is ", exciseTax)
|
||||
|
||||
print("First years expense is ", monthlyPayment*12 + salesTax + exciseTax)
|
||||
14
homework/homework04/results/rectangles001.py
Normal file
14
homework/homework04/results/rectangles001.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
length = 4
|
||||
width = 3
|
||||
|
||||
# The next line is for the column headers
|
||||
print("length width area")
|
||||
|
||||
# The next two lines generate multiple lengths and widths.
|
||||
for length in range(1, 3):
|
||||
for width in range(2, 6):
|
||||
# The next two lines calculate the area then print the values.
|
||||
# Modify the print statement to line up the columns aligned right.
|
||||
area = length * width
|
||||
print(f"{length} {width} {area}")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue