I have this code and I get an error when I tried to convert to farenheit. It's basically a windchill calculator:
import math
c = ""
f = ""
t = 0
def temp (t):
t = (9/5 * temp_chosen) + 32
temp_chosen = float(input("What is the temperature? :"))
scale = input("Farenheit or Celsius (F/C)? ").upper()
def wind():
if scale == "C":
return (t)
print(t)
else:
t = temp_chosen
print(t)
for i in range (5, 65, 5):
wind_chill = 35.74 + (0.6215 * t) -35.75 * (i ** 0.16) + 0.4275 * ((t)) * (i ** 0.16)
print(f"At temperature {t}F, and wind speed {i} mph, the windchill is: {wind_chill:.2f}F")
temp (t)
wind ()
And I get this error:
Traceback (most recent call last):
File "c:/Users/Azevedo/Documents/Codes/test.py", line 28, in <module>
wind ()
File "c:/Users/Azevedo/Documents/Codes/test.py", line 14, in wind
return (t)
UnboundLocalError: local variable 't' referenced before assignment
How can I fix that?