Python Forum
Non Grade/School Help - PLEASE
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Non Grade/School Help - PLEASE
#5
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:

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.
Reply


Messages In This Thread
Non Grade/School Help - PLEASE - by gbyrne12 - Jun-17-2021, 09:29 PM
RE: Non Grade/School Help - PLEASE - by snippsat - Jun-17-2021, 09:52 PM
RE: Non Grade/School Help - PLEASE - by gbyrne12 - Jun-17-2021, 10:08 PM
RE: Non Grade/School Help - PLEASE - by snippsat - Jun-17-2021, 10:42 PM
RE: Non Grade/School Help - PLEASE - by gbyrne12 - Jun-18-2021, 12:53 AM
RE: Non Grade/School Help - PLEASE - by buran - Jun-18-2021, 04:50 AM
RE: Non Grade/School Help - PLEASE - by snippsat - Jun-18-2021, 11:37 AM
RE: Non Grade/School Help - PLEASE - by gbyrne12 - Jun-18-2021, 11:59 AM
RE: Non Grade/School Help - PLEASE - by snippsat - Jun-19-2021, 07:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Method to calculate average and grade ajitnayak1987 8 6,405 Apr-28-2022, 06:26 AM
Last Post: rayansaqer
  Calculating Grade Average IstvanCH 5 5,152 Jan-27-2019, 04:42 PM
Last Post: aakashjha001
  Student grade program help debug ccm1776 3 5,211 Nov-14-2018, 02:41 AM
Last Post: stullis
  Grade Loop dtweaponx 8 12,467 Oct-17-2017, 02:01 PM
Last Post: buran
  Help? Letter Grade assignment.. zepel 3 4,654 Apr-23-2017, 12:47 PM
Last Post: idontreallywolf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020