Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- ### Ejemplo de template While True para resolver ejercicios
- def validar(escala):
- while True:
- try:
- n = float(input(f"Ingrese la temperatura (en {escala}): "))
- except ValueError:
- print("Error, debe ingresar una temperatura válida")
- else:
- return n
- def menu():
- print("""
- Menu de opciones
- ----------------
- 1. ºC a ºF
- 2. Opcion 2
- 3. Opcion 3
- 4. Salir
- """)
- opcion = input("Ingrese una opción: ")
- return opcion
- while True:
- opcion = menu()
- if opcion == "1":
- temp = validar("ºC")
- elif opcion == "2":
- pass
- elif opcion == "3":
- pass
- elif opcion == "4":
- print("Gracias por utilizar este programa...")
- break
- else:
- print("Opción incorrecta...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement