Skip to content

Commit 0c46245

Browse files
Create 2469. Convert the Temperature.py
1 parent 5888590 commit 0c46245

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def convertTemperature(self, celsius: float) -> List[float]:
3+
"""
4+
convertTemperature returns temperature in Kelvin and Fahrenheit when given Celsius input
5+
celsius: float (0 <= celsius <= 1000)
6+
"""
7+
kelvin_fahrenheit_array = [] #create array for kelvin and fahrenheit results
8+
kelvin = celsius + 273.15 #calculate kelvin
9+
kelvin_fahrenheit_array.append(kelvin) #add kelvin to array
10+
fahrenheit = celsius * 1.80 + 32.00 #calculate fahrenheit
11+
kelvin_fahrenheit_array.append(fahrenheit) #add fahrenheit to array
12+
return kelvin_fahrenheit_array

0 commit comments

Comments
 (0)