Convert the Temperature

The problem requires you to convert a given temperature from Celsius to Kelvin and Fahrenheit.

Python solution.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class Solution:
    def convertTemperature(self, celsius: float) -> List[float]:
        # Create a list to store the converted temperatures
        temperature_conversions = []

        # Conversion to Kelvin
        kelvin = celsius + 273.15
        temperature_conversions.append(kelvin)

        # Conversion to Fahrenheit
        fahrenheit = celsius * 1.80 + 32.00
        temperature_conversions.append(fahrenheit)

        return temperature_conversions

In this solution, we first declare a list named temperature_conversions to hold the converted temperature values. Then, we convert the input temperature from Celsius to Kelvin and Fahrenheit according to the provided formulas. We append the converted temperatures to the temperature_conversions list. Finally, we return the list.