Advertisement
teslariu

menu con while true

Nov 12th, 2022
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4.  
  5. # TEMPLATE MENU CON WHILE TRUE
  6.  
  7. # Script que convierte temperaturas de ºC a ºF y viceversa
  8.  
  9. print("""
  10. Conversor de temperaturas
  11. =========================
  12. """)
  13. while True:
  14.    
  15.     print("""
  16.    Menu de opciones
  17.    ----------------
  18.    1. ºC --> ºF
  19.    2. ºF --> ºC
  20.    3. Salir
  21.    """)
  22.     opcion = input("Seleccione una opción: ")
  23.    
  24.     if opcion == "1":
  25.         temp = float(input("Ingrese la temperatura: "))
  26.         print(f"Temperatura: {temp * 1.8 + 32:.1f}ºF")
  27.        
  28.     elif opcion == "2":
  29.         temp = float(input("Ingrese la temperatura: "))
  30.         print(f"Temperatura: {(temp - 32 ) / 1.8:.1f}ºC")
  31.        
  32.     elif opcion == "3":
  33.         print("Gracias por usar este programa...")
  34.         break
  35.        
  36.     else:
  37.         print("Opción incorrecta")
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement