基本贷款计算器

问题描述:

我知道我有点愚蠢,但我一直试图让这个简单的代码(计算项目的一部分)的四舍五入到小数点后第二位,到目前为止我没有'不能这样做。基本贷款计算器

loan = float(input("Please enter Amount that you would like to borrow (£):")) 
loanduration = float(input("Please enter Duration of the loan(Months):")) 


print("You will pay (£)" ,loan/loanduration, "per month") 



It outputs like so 
Please enter Amount that you would like to borrow (£):4000 
Please enter Duration of the loan(Months):12 
You will pay (£) 333.3333333333333 per month 
>>> 

loan = float(input("Please enter Amount that you would like to borrow (£): ")) 
loanduration = float(input("Please enter Duration of the loan(Months): ")) 
print("You will pay (£) %.2f per month" % (loan/loanduration)) 

用法示例:

Please enter Amount that you would like to borrow (£): 4000 
Please enter Duration of the loan(Months): 12 
You will pay (£) 333.33 per month 

试试吧here!

+1

谢谢你帮我这个,因为它是一个深夜,我完全忘了这一点 –