# "{:.2f}".format
def setup():
loan(5000,0.12,1); #5000baht 12percent 1year
def loan(amt,rate,yr):
month=yr*12;
ratepm=rate/12; #rate per month per year
ppm=amt * ( ratepm / (1 - pow(1 + ratepm,-month))); #(pri+interest)
pri=ppm; #principal
unpaid=amt; #unpaid
total_interest=0;
i=1;
print("No. Interest Principal Unpaid total interest");
while (i<=month):
print(i,end=' '); #NO.
print(" ","{:10.2f}".format(ratepm*unpaid),end=' '); #interest 10.2
total_interest+=ratepm*unpaid;
pri=ppm-(ratepm*unpaid);
unpaid-=pri;
if (unpaid<0):
unpaid=0
print(" ","{:.2f}".format(pri),end=' ') #principal
print(" ","{:.2f}".format(unpaid),end=' ') #unpaid
print(" ","{:.2f}".format(total_interest),end=' ')#total_interest
print()
i+=1
setup()
วันพฤหัสบดีที่ 17 กันยายน พ.ศ. 2558
Lab4x : Loan
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
commit เพิ่มเติม : เพื่ม userstory, bookmark
>> add userstory ทำการเพิ่ม userstory ใน functional tests >> add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...
-
1 2 3 4 5 6 7 8 9 def setup (): print (d2b( 8 )) def d2b (num): x = "" while num > 0 : x = str ( int (n...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 def test_layout_and_styling ( self ): # Edith goes to the home page self . brow...
-
การใช้ template inheritence คือการสืบทอดเทมเพลต เพื่อให้ไม่ต้องเขียนโค้ดหน้าเว็บๆซ้ำๆ เราจะมีหน้าหลักอันเดียว (base.html or parent) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น