Program w Pythonie do konwersji stopni Celsjusza na Fahrenheita

Spisie treści

W tym programie nauczysz się przeliczać Celsuis na Fahrenheit i wyświetlać to.

Aby zrozumieć ten przykład, powinieneś znać następujące tematy programowania w Pythonie:

  • Typy danych w Pythonie
  • Wejście, wyjście i import języka Python
  • Operatory Pythona

W poniższym programie bierzemy temperaturę w stopniach Celsjusza i konwertujemy ją na stopnie Fahrenheita. Związane są one wzorem:

 Celsjusza * 1,8 = Fahrenheita - 32 

Kod źródłowy

 # Python Program to convert temperature in celsius to fahrenheit # change this value for a different result celsius = 37.5 # calculate fahrenheit fahrenheit = (celsius * 1.8) + 32 print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit)) 

Wynik

 37,5 stopnia Celsjusza to 99,5 stopnia Fahrenheita 

Zachęcamy do stworzenia programu w języku Python do samodzielnego przeliczania stopni Fahrenheita na stopnie Celsjusza za pomocą następującego wzoru

 celsius = (fahrenheit - 32) / 1.8 

Interesujące artykuły...