Example 1
Input Fahrenheit temperature: 77.9
Output Celsius temperature: 25.5
Scientific temperatures
You will learn about: submitting code and temperature conversion.
We'll get you familiar with how submitting code to Project Lovelace works by converting some temperatures. Scientists like to use Celsius instead of Fahrenheit but sometimes you're given a temperature in Fahrenheit and you have to convert it to Celsius. It's pretty easy: subtract 32 then multiply by 5/9 or if you like equations $$ C = \frac{5}{9} (F - 32) $$ In the code editor below try to write a function fahrenheit_to_celsius(F) that converts Fahrenheit to Celsius and we'll test your code when you submit it to make sure you got it right.
Input: The temperature in Fahrenheit (°F).
Output: The temperature in Celsius (°C).
Difficulty | Timesink | ||
---|---|---|---|
Maximum runtime | 60 s | Max. memory usage | 250 MiB |
Function signature | fahrenheit_to_celsius(F) |
Write a function that accepts the input as function parameters and returns the correct output. Make sure to read the description above to produce the correct output in the correct format and use the correct function signature so we can run your code. A good first step is to try reproducing the example(s). Your code must not take longer than the maximum runtime to run and must not use more memory than the allowed limit.
You must be logged in to view your submissions.
Let us know what you think about this problem! Was it too hard? Difficult to understand? Also feel free to discuss the problem, ask questions, and post cool stuff on Discourse. You should be able see a discussion thread below. Feel free to post your solutions but if you do please organize and document your code well so others can learn from it.