Exercise · Variables and types · lesson 7 of 7
Exercise: Fahrenheit
Write a function to_fahrenheit(celsius) that returns the temperature celsius in degrees Fahrenheit. Degrees Celsius convert to them by the formula F = C * 1.8 + 32.
to_fahrenheit(100)→212.0to_fahrenheit(-40)→-40.0to_fahrenheit(36.6)→97.88
Constraints: celsius is an int or a float not below absolute zero (−273.15 °C). The result is compared with the expected one approximately: the last digits of fractional numbers may differ. In the tests the helper close does this: its check isinstance(got, (int, float)) accepts both int and float.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.