Temperature Converter With a Proper Docstring

Easy ⏱ 8 min 73% acceptance ★★★★★ 4.5
Write a function celsius_to_fahrenheit(celsius) that converts a Celsius temperature to Fahrenheit using the formula F = C * 9/5 + 32, rounded to 1 decimal place. Include a one-line docstring describing what the function does (the docstring itself is not graded on wording, but the function must have one).

Examples

Example 1
Input
celsius_to_fahrenheit(0)
Output
32.0
Explanation

0C is exactly 32F.

Example 2
Input
celsius_to_fahrenheit(37)
Output
98.6
Explanation

37 * 9/5 + 32 = 98.6.

Constraints

  • Result rounded to 1 decimal place.

Topics

Functionsdocstrings

Companies

TCSAccenture

Hints

Hint 1

A docstring is a string literal right after the def line, e.g. """Converts Celsius to Fahrenheit."""

Hint 2

Use round(value, 1).

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.