Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Hacer un programa usando funciones que convierta temperaturas de
- ºF a ºC y viceversa
- EJ:
- >>> Menu
- 1. Pasar a ºC
- 2. Pasar a ºF
- Ingrese su opcion:
- F = C*1.8 + 32
- C = (F-32) / 1.8
- """
- def conversion(numero):
- temp = float(input("Ingrese la temperatura: "))
- if numero == 1:
- print(f"{temp}ºF equivalen a {(temp-32)/1.8}ºC")
- else:
- print(f"{temp}ºC equivalen a {temp * 1.8 + 32}ºF")
- while True:
- print("\nPrograma de conversión de temperaturas")
- print("--------------------------------------")
- print("1. Conversión de ºF a ºC")
- print("2. Conversión de ºC a ºF")
- print("3. Salir")
- opcion = input("Seleccione una opción: ")
- if opcion == "1":
- conversion(1)
- elif opcion == "2":
- conversion(2)
- elif opcion == "3":
- print("Hasta pronto....")
- break
- else:
- print("Opción incorrecta")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement