teslariu

menu

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