Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- #
- """
- Script que pide una temp en ºF y la pasa a ºC o viceversa
- """
- def menu():
- return """
- Menu de conversión de temperaturas:
- -----------------------------------
- 1. ºC --> ºF
- 2. ºF --> ºC
- 3. Salir
- -----------------------------------
- """
- def ingresar_temperatura():
- temp = float(input("Ingrese la temperatura: "))
- retutn temp
- def convertir_a_farenheit(temp):
- return temp * 1.8 + 32
- def convertir_a_celsius(temp):
- return (temp - 32) / 1.8
- while True:
- print(menu())
- opcion = input("Seleccione una opcion: ")
- if opcion == "1":
- temp = ingresar_temperatura()
- print(convertir_a_farenheit(temp))
- elif opcion == "2":
- temp = ingresar_temperatura()
- print(convertir_a_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