화씨 온도(°F)를 섭씨 온도(°C)로 바꾸어주는 프로그램을 만들려고 합니다.
섭씨와 화씨의 관계식은 다음과 같습니다:
화씨 온도를 섭씨 온도로 변환해 주는 함수 fahrenheit_to_celsius를 써 보세요. 이 함수를 파라미터로 화씨 온도 fahrenheit를 받고, 변환된 섭씨 온도를 리턴합니다.
위 프로그램을 실행하면 아래처럼 출력되어야 합니다.
# 화씨 온도에서 섭씨 온도로 바꿔 주는 함수
def fahrenheit_to_celsius(fahrenheit):
celsius_list = []
for i in fahrenheit:
celsius = round((i - 32) * 5 / 9, 1)
celsius_list.append(celsius)
return celsius_list
temperature_list = [40, 15, 32, 64, -4, 11]
print("화씨 온도 리스트: " + str(temperature_list)) # 화씨 온도 출력
print("섭씨 온도 리스트: " + str(fahrenheit_to_celsius(temperature_list))) # 섭씨 온도 출력
'코드잇' 카테고리의 다른 글
[코드잇] 단어장 만들기>단어 퀴즈>고급 단어장 (1) | 2021.01.30 |
---|---|
[코드잇] 코딩에 빠진 닭 (0) | 2021.01.27 |
[코드잇] 숫자 맞히기 게임 (0) | 2021.01.27 |
[코드잇] 피보나치 수열 (2) | 2021.01.20 |
[코드잇] 반복문,조건문 사용하여 코드 만들기 (0) | 2021.01.20 |