Advertisement
teslariu

menu template

Apr 20th, 2023
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """
  5. Ejemplo de una plantilla de menu
  6. Script que convierte temp de ºC a ºF y viceversa
  7. """
  8.  
  9. print("""
  10. Conversor de temperaturas
  11. =========================
  12. Menu de opciones
  13. ----------------
  14. 1. ºC -> ºF
  15. 2. ºF -> ºC
  16. ----------------
  17. """)
  18. opcion = input("Seleccione una opcion: ")
  19.  
  20. if opcion == "1":
  21.     temp = float(input("Ingrese la temperatura: "))
  22.     print(f"{temp:.1f}ºC equivalen a {temp*1.8 + 32:.1f}ºF")
  23.    
  24. elif opcion == "2":
  25.     temp = float(input("Ingrese la temperatura: "))
  26.     print(f"{temp:.1f}ºF equivalen a {(temp - 32) / 1.8:.1f}ºC")
  27.    
  28. else:
  29.     print("Opción incorrecta")
  30.    
  31.    
  32.    
  33.    
  34.    
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement