# 獎金計算
def countBonus():
earnings = int(input("請輸入收益"))
if earnings <= 10 :
bouns = earnings * 0.1
elif earnings > 10 and earnings <=20:
bonus = 10 * 0.1 + (earnings - 10) * 0.075
elif earnings > 20 and earnings <=40:
bonus = 10 * 0.1+ 10 * 0.075 + (earnings-20) * 0.05
elif earnings > 40 and earnings <= 60:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (earnings - 40) * 0.03
elif earnings > 60 and earnings <= 100:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (earnings - 60 ) * 0.015
elif earnings > 100:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40 * 0.015 + (earnings - 100) * 0.01
print("你的總收益是", earnings, "萬元")
print("你的獎金是", bonus, "萬元")
countBonus()
然后結果直接就弾了一個
Process finished with exit code 0
怎么解決呀
uj5u.com熱心網友回復:
countBonus() 去掉此陳述句前的四個空格。uj5u.com熱心網友回復:
去了也不行,是不是解釋器的原因?
uj5u.com熱心網友回復:
是彈出新視窗還是在控制臺中列印輸出,這個算是正常資訊,表示程式已經運行結束了,不是什么錯誤資訊.如果是彈出新視窗可以嘗試在pycharm的settings中找找看看在哪里可以設定顯示方式. 如果是在控制臺中列印輸出就直接忽略就好了.
uj5u.com熱心網友回復:
控制臺,run之后顯示的,我input沒地方輸入,也不顯示,求教怎么設定
uj5u.com熱心網友回復:
看了下你的代碼, 是縮進問題, 因為你的countBonus方法根本就沒有呼叫, 把呼叫的哪行代碼的縮進去掉就好了.如下
# 獎金計算
def countBonus():
earnings = int(input("請輸入收益"))
if earnings <= 10 :
bouns = earnings * 0.1
elif earnings > 10 and earnings <=20:
bonus = 10 * 0.1 + (earnings - 10) * 0.075
elif earnings > 20 and earnings <=40:
bonus = 10 * 0.1+ 10 * 0.075 + (earnings-20) * 0.05
elif earnings > 40 and earnings <= 60:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (earnings - 40) * 0.03
elif earnings > 60 and earnings <= 100:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (earnings - 60 ) * 0.015
elif earnings > 100:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40 * 0.015 + (earnings - 100) * 0.01
print("你的總收益是", earnings, "萬元")
print("你的獎金是", bonus, "萬元")
countBonus()
至于Process ...那句話只是代碼程式已經運行結束直接忽略就好了.
uj5u.com熱心網友回復:
還有那兩個print的縮進也去掉
uj5u.com熱心網友回復:
設定問題,請查看我的博客。https://blog.csdn.net/D515756463/article/details/103660584uj5u.com熱心網友回復:
Process finished with exit code 0說明程式是正常運行結束的,非0狀態碼是因意外結束的,所有要么def的函式呼叫完了,要么壓根就沒有呼叫
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/110748.html
下一篇:牛角尖問題系列 恭請大神
