Thanks, also stuck on this one:
In the code cell below, create a method that convert temperature from fahrenheit to celcius and another method that does the reverse.
The beginning of the methods is given below:
In the code cell below, create a method that convert temperature from fahrenheit to celcius and another method that does the reverse.
The beginning of the methods is given below:
def celToFah(celcius): fahrenheit = (celcius * 9/5) + 32 print('%.2f celcius is: %0.2f fahrenheit' %(celcius, fahrenheit)) def fahToCel(fahrenheit): celcius = (fahrenheit - 32) * 5/9 print('%.2f fahrenheit is: %0.2f celcius' %(fahrenheit, celcius)) # Get the temperature in celcius from user and display equivalent temperature in fahrenheit cel = float(input('Enter the temperature in celcius:')) return 'The temperature in Fahrenheit = ' + str(celToFah(cel)) # Get the temperature in fahrenheit from user and display equivalent temperature in celcius fah = float(input('Enter the temperature in fahrenheit: ')) print('The temperature in celcius = ' + str(fahToCel(fah)))
Error:Enter the temperature in celcius:10
File "<ipython-input-5-89452f5b965c>", line 12
return 'The temperature in Fahrenheit = ' + str(celToFah(cel))
^
SyntaxError: 'return' outside function
buran write Jun-18-2021, 04:49 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.