Advertisement
teslariu

while true

Oct 30th, 2021
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Programa que pide una temperatura en ºC y la convierte a ºF o viceversa
  5.  
  6. while True:
  7.     print("\nPrograma de conversión de temperaturas")
  8.     print("--------------------------------------")
  9.     print("""Menu de opciones
  10.         1. ºF -> ºC
  11.         2. ºC --> ºF
  12.         3. Salir
  13.     """)
  14.  
  15.     opcion = input("Elija su opción: ")
  16.  
  17.     if opcion == "1":
  18.         temp = float(input("Ingrese la temperatura: "))
  19.         print(f"La temperatura equivale a {(temp-32) / 1.8}ºC")
  20.  
  21.     elif opcion == "2":
  22.         temp = float(input("Ingrese la temperatura: "))
  23.         print(f"La temperatura equivale a {temp * 1.8 + 32}ºF")
  24.        
  25.     elif opcion == "3":
  26.         print("Gracias por usar este programa....")
  27.         break
  28.    
  29.     else:
  30.         print("Opción incorrecta ...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement