teslariu

menu while true

Jun 24th, 2023
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. 3) Ingresar una temp y convertirla. El script debe pasar de ºC -> ºF y viceversa. Test: 10ºC = 50ºF
  5. """
  6.  
  7. menu = """
  8. Menu de opciones:
  9. -----------------
  10. 1. ºC --> ºF
  11. 2. ºF --> ºC
  12. 3. Salir
  13. -----------------
  14. """
  15.  
  16. while True:
  17.     print(menu)
  18.  
  19.     opcion = input("Seleccione una opción: ")
  20.  
  21.     if opcion == "1":
  22.         temp = float(input("Ingrese la temperatura: "))
  23.         temp = temp * 1.8 + 32
  24.         print(f"Temperatura: {temp:.1f}ºF")
  25.  
  26.     elif opcion == "2":
  27.         temp = float(input("Ingrese la temperatura: "))
  28.         temp = (temp - 32) / 1.8
  29.         print(f"Temperatura: {temp:.1f}ºC")
  30.  
  31.     elif opcion == "3":
  32.         print("Gracias por utilizar este programa")
  33.         break
  34.  
  35.     else:
  36.         print("Opción equivocada")
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment