teslariu

template menu sin while

Jun 24th, 2023
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. 3) Ingresar una temp y convertirla. El script debe pasar de ºC -> ºF y viceversa. Test: 10ºC = 50ºF
  5. """
  6.  
  7. menu = """
  8. Menu de opciones:
  9. -----------------
  10. 1. ºC --> ºF
  11. 2. ºF --> ºC
  12. -----------------
  13. """
  14.  
  15. print(menu)
  16.  
  17. opcion = input("Seleccione una opción: ")
  18.  
  19. if opcion == "1":
  20.     temp = float(input("Ingrese la temperatura: "))
  21.     temp = temp * 1.8 + 32
  22.     print(f"Temperatura: {temp:.1f}ºF")
  23.  
  24. elif opcion == "2":
  25.     temp = float(input("Ingrese la temperatura: "))
  26.     temp = (temp - 32) / 1.8
  27.     print(f"Temperatura: {temp:.1f}ºC")
  28.  
  29. else:
  30.     print("Opción equivocada")
  31.  
Advertisement
Add Comment
Please, Sign In to add comment