elizeub

Contador de cédulas de dinheiro em Python

Aug 18th, 2021 (edited)
1,982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #  ContadorDeNotas.py
  5. #  
  6. #  Copyright 2021  <pi@suelizeuadrian>
  7. #  
  8. #  This program is free software; you can redistribute it and/or modify
  9. #  it under the terms of the GNU General Public License as published by
  10. #  the Free Software Foundation; either version 2 of the License, or
  11. #  (at your option) any later version.
  12. #  
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #  
  18. #  You should have received a copy of the GNU General Public License
  19. #  along with this program; if not, write to the Free Software
  20. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. #  MA 02110-1301, USA.
  22. #  
  23. #  
  24.  
  25. # CRIA UMA FUNÇÃO COM UM LOOP QUE SUBTRAI UMA NOTA DO VALOR DADO COMEÇANDO
  26. # PELA MAIOR NOTA DAS NOTAS DEFINIDAS  NA LISTA 'NOTAS', ATÉ QUE O VALOR
  27. # RESTANTE SEJA 0
  28. def contarnotas(notas, x, count, valor):
  29.    
  30.     print('\n\033[7m{:^50}\033[m'.format('Pegue as notas: '))
  31.     print(f'\nR${valor:2.2f} => ', end='')
  32.    
  33.     if valor >= 1:
  34.        
  35.         for n in notas:
  36.            
  37.             while valor >= (notas[x]):          
  38.                 count += 1
  39.                 valor -= (notas[x])
  40.      
  41.                 if valor < (notas[x]):
  42.                     print('[', end='')
  43.                     print(f'{count:0>2} notas de R${(notas[x]):2.2f}', end='')
  44.                     print(']', end=' ')                
  45.                     x += 1
  46.                     count = 0
  47.                    
  48.                 if valor == 0:
  49.                    
  50.                     break
  51.             else:
  52.                 x += 1
  53.  
  54.            
  55. # LISTA DAS NOTAS DISPONIVEIS E DEFINIÇÕES DAS VARIÁVEIS
  56. notas = [100, 50, 20, 10, 5, 2, 1, 0]
  57. x = count = valor = 0  
  58.  
  59. # ENTRADA DO VALOR PELO USUAŔIO
  60. print('\033[7m{:^50}\033[m'.format('CONTADOR DE CÉDULAS'))
  61.  
  62.  
  63. print('''Este banco tem notas de:
  64.  
  65.     -R$100.00
  66.     -R$50.00
  67.     -R$20.00
  68.     -R$10.00
  69.     -R$5.00
  70.     -R$2.00
  71.     -R$1.00
  72. ''')
  73.  
  74. while True:
  75.    
  76.     entrada = str(input('\nQuantos Reais você deseja sacar? >>>>>>> R$'))
  77.    
  78.     if entrada.isnumeric() and entrada != '0':
  79.         valor = int(entrada)   
  80.         break              
  81.     else:
  82.         print('\nFavor digitar valor numérico, inteiro e maior ou igual a R$1,00')
  83.        
  84.    
  85. contarnotas(notas, x, count, valor)
  86.  
Add Comment
Please, Sign In to add comment