Programa Python para converter Celsius em Fahrenheit

Índice

Neste programa, você aprenderá a converter Celsuis em Fahrenheit e exibi-lo.

Para entender este exemplo, você deve ter conhecimento dos seguintes tópicos de programação Python:

  • Tipos de dados Python
  • Entrada, saída e importação do Python
  • Operadores Python

No programa abaixo, pegamos uma temperatura em graus Celsius e a convertemos em graus Fahrenheit. Eles estão relacionados pela fórmula:

 celsius * 1.8 = fahrenheit - 32 

Código fonte

 # 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)) 

Resultado

 37,5 graus Celsius é igual a 99,5 graus Fahrenheit 

Nós o encorajamos a criar um programa Python para converter Fahrenheit para Celsius por conta própria usando a seguinte fórmula

 celsius = (fahrenheit - 32) / 1.8 

Artigos interessantes...