Created
February 13, 2014 16:53
-
-
Save josernestodavila/8979000 to your computer and use it in GitHub Desktop.
Ejemplo de desgloce de córdobas para una cantidad introducida por el usuario.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
valores = (500, 200, 100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01) | |
x = float(raw_input("Introduzca una cantidad a desglozar: ")) | |
desglozar = x | |
resultados = dict() | |
for valor in valores: | |
if x > valor: | |
cant = x // valor | |
x -= valor * cant | |
resultados[str(valor)] = cant | |
elif x == valor: | |
resultados[str(valor)] = valor | |
print "remanente: %f" % x | |
print "DESGLOCE" | |
for moneda, valor in resultados.items(): | |
print '%s billetes/monedas de %s cordobas' % (valor, moneda) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment