私は数ヶ月前にpythonを始めました。風の寒さを計算するためにネストされたループを使用するタスクが与えられました。WindchillネストされたループPythonコードの式
私はコードの大部分を完成しましたが(私は思いますが)、式は機能しないと考えています。ここで
は、現時点では私のコードです:これはこれで出てくる
def main():
temp = 0
wind = 0
windChill = 13.12 + (.6215 * temp) - (11.37 * wind ** 770.16) + (.3965 * temp * wind **0.16)
for temp in range(-35,15,5):
print 'temperature is %d' % temp
for wind in range(0,85,5):
answer = float(windChill)
print 'wind is %d calculated wind chill is: %d' % (wind, answer)
main()
:13がアウトspitedている理由私は理解して
temperature is -35
wind is 0 calculated wind chill is: 13
wind is 5 calculated wind chill is: 13
wind is 10 calculated wind chill is: 13
wind is 15 calculated wind chill is: 13
wind is 20 calculated wind chill is: 13
wind is 25 calculated wind chill is: 13
wind is 30 calculated wind chill is: 13
wind is 35 calculated wind chill is: 13
wind is 40 calculated wind chill is: 13
wind is 45 calculated wind chill is: 13
wind is 50 calculated wind chill is: 13
wind is 55 calculated wind chill is: 13
wind is 60 calculated wind chill is: 13
wind is 65 calculated wind chill is: 13
wind is 70 calculated wind chill is: 13
wind is 75 calculated wind chill is: 13
wind is 80 calculated wind chill is: 13
temperature is -30
wind is 0 calculated wind chill is: 13
TEMPと風が0であるかのため、それは、ですそれは答え13.12に来る。しかし、私が気温と風の定義の範囲を行うと、それは定義のリストを受け入れません。
風の寒さは13ではなく、式が吐き出されるようにします。
temperature is -35
wind is 0 calculated wind chill is: -8.63
wind is 5 calculated wind chill is: -41.29
wind is 10 calculated wind chill is: -45.12
etc.
etc.
ありがとうございました!
私が置いたものがシンプルで、私はちょうどそれをgoogleする必要があります、私はそれを検索しようとしましたが、ステートメントの代わりにテーブルを作成します。
カーニー。
あなたは同じ 'windChill'値を何度も繰り返し使用しています。期待どおりの価値を得るためには、そこにある計算を適用する必要がありますか? – idjaw
あなたのコードをもう一度見て、 'windChill'の計算があなたのループ内にあるべきではありませんか? – idjaw
ええ、下のmistermiyagiは私を修正しました。それを見ると、明らかになったようですが、私は何の手がかりも持たない年齢のためにそれを見ていました。そんなばかげた質問を申し訳ありません。ご協力ありがとうございました。 – CarnivorousMonster