Advertisement
teslariu

conversion

May 15th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Hacer un programa usando funciones que convierta temperaturas de
  6. ºF a ºC y viceversa
  7. EJ:
  8. >>> Menu
  9.    1. Pasar a ºC
  10.    2. Pasar a ºF
  11.    
  12.    Ingrese su opcion:
  13.    
  14.    F = C*1.8 + 32
  15.    C = (F-32) / 1.8
  16.  
  17. """
  18. def conversion(numero):
  19.     temp = float(input("Ingrese la temperatura: "))
  20.     if numero == 1:
  21.         print(f"{temp}ºF equivalen a {(temp-32)/1.8}ºC")
  22.     else:
  23.         print(f"{temp}ºC equivalen a {temp * 1.8 + 32}ºF")
  24.  
  25.  
  26.  
  27. while True:
  28.    
  29.     print("\nPrograma de conversión de temperaturas")
  30.     print("--------------------------------------")
  31.     print("1. Conversión de ºF a ºC")
  32.     print("2. Conversión de ºC a ºF")
  33.     print("3. Salir")
  34.  
  35.     opcion = input("Seleccione una opción: ")
  36.    
  37.     if opcion == "1":
  38.         conversion(1)
  39.                
  40.     elif opcion == "2":
  41.         conversion(2)
  42.        
  43.     elif opcion == "3":
  44.         print("Hasta pronto....")
  45.         break
  46.        
  47.     else:
  48.         print("Opción incorrecta")
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement