Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # uso de break y continue
- """
- numero = 3
- while numero < 10:
- print(numero)
- break # interrumpe el while, me saca del bucle
- print("Fuera del primer bucle")
- while numero < 10:
- print(numero)
- continue # interrumpe el while, lo reinicia
- print("Dentro del while") # nunca se ejecuta
- print("Fuera del bucle")
- """
- # Plantillas o templates
- # Cuando un usuario ejecuta scripts, lo recomendable es que él decida
- # cuando terminar de usarlo
- # Ejemplo de plantilla sin menu
- # Ej: hacer un script que convierta temperaturas expresadas en ºC a ºF
- # valor de test: 10ºC equivalen a 50ºF
- print("Conversor de temperaturas")
- print("-------------------------")
- while True:
- temperatura = int(input("\nIngrese una temperatura (ºC): "))
- print(f"{temperatura}ºC equivalen a {temperatura * 1.8 + 32}ºF")
- opcion = input("Presione cualquier tecla para continuar (o '1' para salir): ")
- if opcion == "1":
- print("Gracias por usar este script...")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement