Advertisement
teslariu

temp

Oct 13th, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #
  5. """
  6. Script que pide una temp en ºF y la pasa a ºC o viceversa
  7. """
  8. def menu():
  9.     return """
  10.     Menu de conversión de temperaturas:
  11.     -----------------------------------
  12.         1. ºC --> ºF
  13.         2. ºF --> ºC
  14.         3. Salir
  15.     -----------------------------------
  16.     """
  17.  
  18. def ingresar_temperatura():
  19.     temp = float(input("Ingrese la temperatura: "))
  20.     retutn temp
  21.  
  22. def convertir_a_farenheit(temp):
  23.     return temp * 1.8 + 32 
  24.  
  25. def convertir_a_celsius(temp):
  26.     return (temp  - 32) / 1.8
  27.  
  28.  
  29. while True:
  30.     print(menu())
  31.  
  32.     opcion = input("Seleccione una opcion: ")
  33.  
  34.     if opcion == "1":
  35.         temp = ingresar_temperatura()
  36.         print(convertir_a_farenheit(temp))
  37.        
  38.    
  39.     elif opcion == "2":
  40.         temp = ingresar_temperatura()
  41.         print(convertir_a_celsius(temp))
  42.        
  43.     elif opcion == "3":
  44.         print("Gracias por usar este programa...")
  45.         break  
  46.    
  47.     else:
  48.         print("Opción incorrecta")
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement