Sep-11-2019, 07:06 AM
Hi guys, thanks for the advice. I went to re-wrote the code by defining all the parameters in a single function.
def convertTemp (temp=0, tempConvert="C"):
if tempConvert == "F":
temp = (temp - 32)/1.8
print("Celsius to Fahrenheit: %.2f" % temp,tempConvert)
elif tempConvert == "C":
temp = (temp * 1.8)+32
print("Fahrenheit to Celsius:",temp,tempConvert)
else:
print("Invalid Temperature type")
print("Temperature type must be either F for Fahrenheit or C for Celsius")
return temp
convertTemp(100,"F")
Perfringo, thanks for the assist! Your code is slightly way too high for me to understand. However, appreciate it anyway.
def convertTemp (temp=0, tempConvert="C"):
if tempConvert == "F":
temp = (temp - 32)/1.8
print("Celsius to Fahrenheit: %.2f" % temp,tempConvert)
elif tempConvert == "C":
temp = (temp * 1.8)+32
print("Fahrenheit to Celsius:",temp,tempConvert)
else:
print("Invalid Temperature type")
print("Temperature type must be either F for Fahrenheit or C for Celsius")
return temp
convertTemp(100,"F")
Perfringo, thanks for the assist! Your code is slightly way too high for me to understand. However, appreciate it anyway.