Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Script que convierte temperaturas no negativas de ºC a ºF y viceversa
- """
- def menu():
- return """
- 1. ºC -> ºF
- 2. ºF -> ºC
- 3. Salir
- """
- def ingresar():
- while True:
- temp = input("Ingrese la temperatura: ")
- if temp.isdecimal():
- return int(temp)
- else:
- print("Debe ingresar un entero no negativo")
- def farenheit(temp):
- return f"{temp * 1.8 + 32}ºF"
- def celsius(temp):
- return f"{(temp - 32) / 1.8:.1f}ºC"
- print("Conversor de temperaturas")
- while True:
- print(menu())
- opcion = input("Seleccione una opcion: ")
- if opcion == "1":
- temp = ingresar()
- print(farenheit(temp))
- elif opcion == "2":
- temp = ingresar()
- print(celsius(temp))
- elif opcion == "3":
- print("Gracias por usar este programa")
- break
- else:
- print("Opción incorrecta")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement