teslariu

while True

May 30th, 2022
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Script que implementa un template para ejcución de un programa
  5. ininterrumpidamente
  6.  
  7. while True:
  8.    programa
  9.    salir con break
  10.  
  11.  
  12.  
  13. """
  14. # Hacer un script que pida una temperatura en ºC y la pase a ºF o viceversa
  15. # 10ºC = 50ºF
  16.  
  17. while True:
  18.     print("""
  19.        Menú de opciones
  20.        ----------------
  21.        1. ºC -> ºF
  22.        2. ºF -> ºC
  23.        3. Salir
  24.        """)
  25.  
  26.     opcion = input("Seleccione una opción: ")
  27.  
  28.     if opcion == "1":
  29.         t = float(input("Ingrese la temperatura: "))
  30.         print(f"{t}ºC equivalen a {t*1.8 + 32:.1f}ºF")
  31.    
  32.     elif opcion == "2":
  33.         t = float(input("Ingrese la temperatura: "))
  34.         print(f"{t}ºF equivalen a {(t - 32) / 1.8:.1f}ºC")
  35.        
  36.     elif opcion == "3":
  37.         print("Gracias por usar este programa...")
  38.         break
  39.        
  40.     else:
  41.         print("Error, opción incorrecta")  
Advertisement
Add Comment
Please, Sign In to add comment