# Determine price per pound
if quantity >= 40:
print('Cost of coffee $', format(quantity * 7.50,'.2f'),sep='')
else:
if quantity >= 20:
print ('Cost of coffee $', format(quantity * 8.75, '.2f'), sep='')
else:
if quantity >= 10:
print ('Cost of coffee $', format (quantity * 10.00, '.2f'), sep='')
else:
if quantity >= 1 or quantity <= 9:
print ('Cost of coffee $', format (quantity * 12.00, '.2f'), sep='')
変数に割り当てられた合計(1ポンドあたりの金額*入力数量)がどのように得られるか把握しようとしています。私は税金の前に合計を取ることができ、7%の税金でそれを倍にすることができる必要があります。上記は数量と価格に基づいてどれくらいの費用がかかっているかを調べなければならない公式です。Pythonは変数名をif else関数に代入します。
インデントを固定します。 –
pythonに 'elif'ブロックがあります –
' quantity 'が9より大きく10より小さい場合どうなりますか? –