Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 21, 2023 16:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
monedas_con_equivalencias = {
"usd": 1,
"mxn": 20,
"eur": 0.81,
"cad": 1.29,
"btc": 0.000088
}
print("Monedas disponibles:")
for moneda in monedas_con_equivalencias:
print(moneda)
nombre_moneda_origen = ""
nombre_moneda_destino = ""
while nombre_moneda_origen not in monedas_con_equivalencias:
nombre_moneda_origen = input("Moneda origen: ")
while nombre_moneda_destino not in monedas_con_equivalencias:
nombre_moneda_destino = input("Moneda destino: ")
cantidad = float(input(f"Ingresa la cantidad de {nombre_moneda_origen}: "))
equivalencia_origen = monedas_con_equivalencias[nombre_moneda_origen]
equivalencia_destino = monedas_con_equivalencias[nombre_moneda_destino]
equivalencia = (equivalencia_destino/equivalencia_origen)*cantidad
print(f"{cantidad:.2f} {nombre_moneda_origen} equivale a {equivalencia:.2f} {nombre_moneda_destino}.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment