print "Olá! Este é um conversor de temperatura de Celcius para Fahrenheit e vice-versa!" ask = raw_input("Escolha para que escala quer converter a temperatura: Celcius ou Fahrenheit?") if ask == "Celcius" or ask == "celcius": temp1 = raw_input("Qual é a temperatura em Fahrenheit?") try: Fahr = float(temp1) except: print "Erro: Coloque um numero para a temperatura" quit() Celcius = (Fahr - 32) / 1.8 print "Estão %3.2f graus Celcius" % Celcius elif ask == "Fahrenheit" or ask == "fahrenheit": temp2 = raw_input("Qual é a temperatura em Celcius?") try: Cel = float(temp2) except: print "Erro: Coloque um numero para a temperatura" quit() Fahrenheit = Cel * 1.8 + 32 print " Estão %3.2f graus Fahrenheit" % Fahrenheit else: print "Escolha entre Celcius e Fahrenheit"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question