Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 21, 2023 16:20
Show Gist options
  • Save parzibyte/92647d028e355eef95c96f2fb4b9bb40 to your computer and use it in GitHub Desktop.
Save parzibyte/92647d028e355eef95c96f2fb4b9bb40 to your computer and use it in GitHub Desktop.
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