Last active
January 29, 2018 16:46
Troco
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
# -*- coding: utf-8 -*- | |
def notas_total(valor): | |
notas = [100, 50, 20, 10, 5, 2, 1] | |
totais = [] | |
for idx, nota in enumerate(notas): | |
totais.append(0) | |
if valor > nota: | |
totais[idx] = int(valor / nota) | |
valor -= totais[idx] * nota | |
return notas, totais | |
numero = int(raw_input()) | |
# numero = 11257 | |
print('Entrada:\n{}\n'.format(numero)) | |
notas, totais = notas_total(numero) | |
print('Saida:') | |
masc = '{} nota{} de R$ {},00' | |
for nota, total in zip(notas, totais): | |
if total: | |
print(masc.format(total, 's' if total > 1 else '', nota)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment