-1

初めての投稿で、Python に頭を悩ませようとして、プログラミングの問題を解決し、セールスウーマンのコミッションを求めています。なんらかの理由で合計コミッションを表示できません。フロートは最終結果にどのように影響しますか? 助けてくれてありがとう。これまでの私のコードは次のとおりです

#input for a sales womans sales per month in dollars, and her comission as a percent
#output comission for the month, need to convert percent to a decimal
#variables: Salesamount (float), comission rate(float) comssisoin earned (float)
#formula: comission earned = sales amount * (comissionrate/100)
print " This program will compute the comission earned for the month based on your sales for the month."
comission_rate = input("what is your comission rate percent? ") 
sales = raw_input("How many sales did you have this month? ")
total_com = sales * (comission_rate / 100)
print " your total comission for the month is "
print total_com
4

1 に答える 1

1

すべての入力値を float に変換する必要があります。

print "This program will compute the comission earned for the month based on your sales for the month."
comission_rate = float(raw_input("what is your comission rate percent? "))
sales = float(raw_input("How many sales did you have this month? "))
total_com = sales * (comission_rate / 100)
print " your total comission for the month is "
print total_com

(間違った入力に対する例外処理は、読者の演習として残されています)

于 2013-09-20T15:01:38.810 に答える