Advertisement
diegomrodrigues

Calcular o valor pago das KWh, de acordo com a instalação

Mar 31st, 2020
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. '''
  2. Calcular o valor pago das KWh, de acordo com a instalação
  3. Diego Mendes Rodrigues
  4. '''
  5. # Usuário informar a qtd de KWh consumida
  6. qtd_kwh = 0
  7. while qtd_kwh <= 0:
  8.   try:
  9.     qtd_kwh = int(input('Quantidade KWh consumida: '))
  10.   except:
  11.     pass
  12.  
  13. # Usuário informar o tipo de instalação
  14. print('\nR - Residencial')
  15. print('C - Comercial')
  16. print('I - Industrial')
  17. while True:
  18.   tipo_instalacao = input('\nTipo de instalação [R-C-I]: ').upper()
  19.   if tipo_instalacao in ['R', 'C', 'I']:
  20.     break
  21.  
  22. # Definir o valor pago por hora
  23. valor_h = 0
  24. if tipo_instalacao == 'R':
  25.   if qtd_kwh <= 500:
  26.     valor_h = 0.4
  27.   else:
  28.     valor_h = 0.65
  29. elif tipo_instalacao == 'C':
  30.   if qtd_kwh <= 1000:
  31.     valor_h = 0.55
  32.   else:
  33.     valor_h = 0.60
  34. elif tipo_instalacao == 'I':
  35.   if qtd_kwh <= 5000:
  36.     valor_h = 0.55
  37.   else:
  38.     valor_h = 0.60
  39.  
  40. # Calcular o preço que será pago
  41. preco_pagar = qtd_kwh * valor_h
  42. print(f'\nO valor que será pago é R$ {preco_pagar:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement