Advertisement
teslariu

while sin menu

Feb 4th, 2022
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # uso de break y continue
  5.  
  6. """
  7. numero = 3
  8.  
  9. while numero < 10:
  10.     print(numero)
  11.     break       # interrumpe el while, me saca del bucle
  12. print("Fuera del primer bucle")
  13.  
  14. while numero < 10:
  15.     print(numero)
  16.     continue        # interrumpe el while, lo reinicia
  17.     print("Dentro del while")  # nunca se ejecuta
  18.  
  19. print("Fuera del bucle")
  20. """
  21. # Plantillas o templates
  22. # Cuando un usuario ejecuta scripts, lo recomendable es que él decida
  23. # cuando terminar de usarlo
  24.  
  25. # Ejemplo de plantilla sin menu
  26. # Ej: hacer un script que convierta temperaturas expresadas en ºC a ºF
  27. # valor de test: 10ºC equivalen a 50ºF
  28. print("Conversor de temperaturas")
  29. print("-------------------------")
  30.  
  31. while True:
  32.     temperatura = int(input("\nIngrese una temperatura (ºC): "))
  33.     print(f"{temperatura}ºC equivalen a {temperatura * 1.8 + 32}ºF")
  34.     opcion = input("Presione cualquier tecla para continuar (o '1' para salir): ")
  35.     if opcion == "1":
  36.         print("Gracias por usar este script...")
  37.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement