Instructions: In Python use one or more loops to solve the following exercises. Do not rely on a fancy formula that you find on the intenet -- that would defeat the purpose of the drill. The answers to some of the problems are given below so you can check them against the output of your loop.
Click Kernel above and make sure your Kernel is Python 3(Anaconda 5). You can also use the Kernel menu to restart the kernel if the program jams up. This sometimes occurs if you ask it to execute an incomplete command that never finishes, or an infinite loop.
You deposit $65 on the first business day of each month into a bank account earning 0.24% interest per month. Interest is paid in the on the last business day of each month. Your first deposit is made on Wednesday, Jan. 2, 2019, you make no other deposits or withdrawals except for the deposits mentioned above, and the interest rate never changes. How much will there be in your account
(a) after the interest is paid on Thursday, Dec. 31, 2026?
On Wed. Jan. 2, 2019 you buy a used car. You agree to pay $9000. You pay a $2000 down payment and finance the rest. Your monthly monthly payments are $150, due on the first business day of each month. Your first monthly payment is due Friday, Feb. 1, 2019. Your last monthly payment will be the amount that you still owe on the car if that amount is less than $150. The finance company charges at 9% annual percentage rate (APR). Assume this means on the last day of each month they charge 1/12 of 9% interest, and the first interest charge occurs on Jan. 30, 2019.
(a) How much will you still owe on the car on Friday, Dec. 31, 2021, after the interest is charged?
(c) If you add up your down payment and all your monthly payments how much will you have paid for the car?
print("you paid $10,647.66")
you paid $10,647.66
A credit union Visa card charges 11.99% annual percentage rate for customers who are in good standing. Assume this means they charge 1/12 of that rate each month. To be in good standing customers who owe money on their cards are required to pay at least a minimum payment each month. According to the credit union the required minimum payment is
3% of your total balance but not less than $25
except if your total balance is less than $25 then you don't pay $25, you just pay off the total balance.
Suppose a customer owes $2500 on his Visa card on Jan. 2, 2019. On the first business day of each month he pays the the minimum payment, and makes no other payments or charges. Interest is charged on the last business day of each month.
(a) How much will the customer owe on his card on Dec, 31, 2021, after the interest for that month is charged?
(b) If he keeps making the minimum payment until the balance on the card is paid off, when will he make his last payment?
(hint: first figure out how many months he makes minimum payments that are over $25. Then figure out how many more months it takes to pay off the card. Be sure to include the last payment.)
owed=2500month=0paid=0min_p=0whileowed>0:month=month+1ifowed>25:min_p=owed*0.03ifmin_p<25:min_p=25else:min_p=owedowed=owed-min_pinterest=owed*0.1199/12owed=owed+interestprint("Total months taken to repay: ",month)years=(int)(month/12)
Total months taken to repay: 94
(c) After he pays off this debt he adds up all the payments that he has made to find out how much it cost to pay off this debt. How much will it have cost to pay off this $2500 debt making minimum payments?
(hint: nearly $3500.)
owed=2500month=0paid=0min_p=0whileowed>0:month=month+1ifowed>25:min_p=owed*0.03ifmin_p<25:min_p=25else:min_p=owedowed=owed-min_pinterest=owed*0.1199/12owed=owed+interestyears=(int)(month/12)m=month%12print("Sum off all payments",month*min_p)
Sum off all payments 1852.5194176436678
(For help with this problem see the section on "Approximate Integration" in your Calculus book -- it's section 6.5 in Stewart's Essential Calculus, Second edition.)
Approximate the integral ∫17x3+2x+1dx by subdividing the interval into n=26 subintervals using
(a) The trapezoid rule:, (a pretty-good approximation formula). If a=x0<x1<x2<⋯<xn=b subdivides [a,b] into n congruent subintervals of equal length
defTrapezoidal(f,a,b,n):dx=(b-a)/float(n)x=0.5*(f(a)+f(b))foriinrange(1,n,1):x=x+f(a+i*dx)returndx*ximportmathasmdeff(x):returnm.sqrt(x**3+2*x+1)a=1;b=7n=26I=Trapezoidal(f,a,b,n)print("The asnswer is, I = ")print(round(I,3))
The asnswer is, I =
(b)Simpson's rule: (generally this is more accurate than the trapezoid rule). If n is even and a=x0<x1<x2<⋯<xn=b subdivides [a,b] into n congruent subintervals of equal length
importmathdeffunc(x):returnmath.sqrt(x**3+2*x+1)defsimpsons_(ll,ul,n):h=(ul-ll)/nx=list()fx=list()i=0whilei<=n:x.append(ll+i*h)fx.append(func(x[i]))i+=1res=0i=0whilei<=n:ifi==0ori==n:res+=fx[i]elifi%2!=0:res+=4*fx[i]else:res+=2*fx[i]i+=1res=res*(h/3)returnreslower_limit=1# Lower limitupper_limit=7# Upper limitn=6# Number of intervalprint("%.6f"%simpsons_(lower_limit,upper_limit,n))