Advertisement
teslariu

conversion

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