Fahrenheit to Celsius and Celsius to Fahrenheit

Your task is to create a function named convert_temperature that converts a temperature value from Fahrenheit to Celsius or vice versa. The function should have the following parameters:

  • temperature: positional-only float representing the temperature to be converted.

  • from_scale: a string that indicates the scale of the provided temperature. It can be 'Fahrenheit' or 'Celsius'.

  • to_scale: a keyword-only argument with a default value of Celsius. This string indicates the scale to which the temperature should be converted. It can be Fahrenheit or Celsius.

The function convert_temperature should return a float that represents the converted temperature value. You can use these conversion formulas:

Celsius to Fahrenheit

Fahrenheit to Celsius

(temperature * 9/5) + 32

(temperature - 32) * 5/9

It is guaranteed that from_scale and to_scale will always be either 'Celsius' or 'Fahrenheit' and they will not be the same.

Input

Output

32 Celsius Fahrenheit

89.6

100 Fahrenheit Celsius

37.77777777777778

0 Celsius Fahrenheit

32.0

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue