Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Programa que pide una temperatura y la convierte de ºC a ºF o viceversa
- def inicio():
- print("Programa de conversión de temperaturas")
- print("=========================================")
- def menu():
- print("\n********** Menu de opciones ************")
- print("\t1. Conversión de ºC a ºF")
- print("\t2. Conversión de ºF a ºC")
- print("\t3. Salir")
- def celsius_a_farenheit():
- temperatura = float(input("Ingrese la temperatura (en ºC): "))
- temperatura = temperatura * 1.8 + 32
- return temperatura
- def farenheit_a_celsius():
- temperatura = float(input("Ingrese la temperatura (en ºF): "))
- temperatura = (temperatura - 32) / 1.8
- return temperatura
- #############################################
- inicio()
- while True:
- menu()
- opcion = input("Seleccione una opción: ")
- if opcion == "1":
- print(f"La temperatura convertida es {celsius_a_farenheit()}ºF")
- elif opcion == "2":
- print(f"La temperatura convertida es {farenheit_a_celsius()}ºC")
- elif opcion == "3":
- print("Gracias por utilizar este programa...")
- break
- else:
- print("Opción incorrecta")
Add Comment
Please, Sign In to add comment