簡體   English   中英

Python。代碼輸出錯誤答案。 數學相關

[英]Python. The code is outputting the wrong answer. Math related

    def compound_interest(principle, time, rate):
    
        amount = principle * (pow((1 + rate / 100), time))
        return amount - principle

print('The compound interest is: ', compound_interest(10000, 10.25, 5))

output 應該是 6288.946267774416,但我得到的是 6488.848034974573。 這里有什么問題?

您在撥打arguments 時不小心調換了時間和評分

你應該稱它為:

compound_interest(10000, 5, 10.25)

不是compound_interest(10000, 10.25, 5)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM