Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Programa que convierte una temp de ºC a ºF y viceversa
- # Template o plantilla while True con menu y funcion borrar pantalla
- def borrarPantalla():
- import os
- if os.name == "posix":
- os.system ("clear")
- else:
- os.system ("cls")
- titulo = "Programa de conversión de temperaturas"
- menu_de_opciones = """
- Menu de opciones:
- -----------------
- 1. ºC a ºF
- 2. ºF a ºC
- 3. Salir
- -----------------
- """
- while True:
- borrarPantalla()
- print(titulo)
- print(menu_de_opciones)
- opcion = input("Ingrese una opción: ")
- if opcion == "1":
- temp = float(input("Ingrese una temperatura: "))
- print(f"{temp}ºC equivalen a {temp * 1.8 + 32}ºF")
- elif opcion == "2":
- temp = float(input("Ingrese una temperatura: "))
- print(f"{temp}ºF equivalen a {(temp - 32) / 1.8:.1f}ºC")
- elif opcion == "3":
- print("Gracias por utilizar este programa...")
- break
- else:
- print("Opción incorrecta")
- input("\nPresione cualquier tecla para continuar")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement