Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Ejemplo de una plantilla de menu con WHILE TRUE
- Script que convierte temp de ºC a ºF y viceversa
- """
- import os #Importamos el modulo os
- import time
- while True:
- print("""
- Conversor de temperaturas
- =========================
- Menu de opciones
- ----------------
- 1. ºC -> ºF
- 2. ºF -> ºC
- 3. Salir
- ----------------
- """)
- opcion = input("Seleccione una opcion: ")
- if opcion == "1":
- temp = float(input("Ingrese la temperatura: "))
- print(f"{temp:.1f}ºC equivalen a {temp*1.8 + 32:.1f}ºF")
- elif opcion == "2":
- temp = float(input("Ingrese la temperatura: "))
- print(f"{temp:.1f}ºF equivalen a {(temp - 32) / 1.8:.1f}ºC")
- elif opcion == "3":
- print("Gracias por usar este script")
- break
- else:
- print("Opción incorrecta")
- time.sleep(5) # espero 5 segundos antes de borrar la pantalla
- # limpiar la pantalla
- # Unix/Linux/MacOS/BSD
- os.system("clear")
- # DOS/Windows
- os.system("cls")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement