whileのループから抜け出した。
pythonで金利計算のプログラム書いてます。
金利のループでwhileを使ったらずっと同じ数値のままでループから抜け出せん。
計算の違いだと思うので、教えて欲しいです。
該当のソースコード
python
1total_cost = int(input('家購入の総額を入力してください')) 2portion_down_payment = 0.25 3current_savings = 0 4r = 0.04 5annual_salary = int(input('年収を入力してください')) 6portion_saved = float(input('貯蓄率を入力してください')) 7monthly_salary = annual_salary/12 8down_payment = total_cost*portion_down_payment 9print(annual_salary) 10print(portion_saved) 11print(total_cost) 12while current_savings < down_payment : 13 print(current_savings) 14 interest_rate = current_savings*r/12 15 current_savings = interest_rate+monthly_salary*portion_saved 16 17 18
実行結果
print(current_savings)でループから抜け出すまでの数字を出したいのですが、どこか計算が違うのかずっと同じ値が出続けます。
どこが違うか教えてください。
プログラムの動き、各変数の意味、あるデータ例に対する理想の結果について追記くださると回答得られやすいです。
回答1件
あなたの回答
tips
プレビュー