Advertisement
teslariu

ej3

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