Advertisement
JPablos

Convertir Grados ºC / ºF Simple Python

Feb 7th, 2024 (edited)
1,289
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. """
  2. Convertir grados Farenheit a Celsius
  3. Convertir grados Celsius a Farenheit
  4. """
  5.  
  6. def fahrenheit_a_celsius(_fah):
  7.     """Convertir grados Farenheit a Celsius"""
  8.     return (_fah - 32) / 1.8
  9.  
  10. # Modo de uso
  11. _fah = float(input("Ingresa los grados Fahrenheit: "))
  12. _cel = format(fahrenheit_a_celsius(_fah), '.2f')
  13. print(f"Los {_fah} grados Fahrenheit son {_cel} grados Celsius")
  14.  
  15.  
  16. def celsius_a_fahrenheit(_cel):
  17.     """Convertir grados Celsius a Farenheit"""
  18.     return (_cel * 1.8) + 32
  19.  
  20. # Modo de uso
  21. _cel = float(input("Ingresa los grados Celsius: "))
  22. _fah = format(celsius_a_fahrenheit(_cel), '.2f')
  23. print(f"Los {_cel} grados Celsius son {_fah} grados Fahrenheit")
  24.  
Advertisement
Comments
  • JPablos
    1 year
    # text 0.15 KB | 0 0
    1. Un ejercicio interesante sería crear una aplicación con TkInter.
    2. Parḿetros:
    3. Crear un selector de conversión para seleccionar la función a ejecutar.
  • JPablos
    1 year (edited)
    Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement