0

I'm using PyCharm. This code works fine but my teacher wants me to include a function before every "while True" but when I do the code stops before "def" and I get "process finished with exit code 0" which means no error but the code doesn't run, example:

'''

def metragem_valor():


  while true
    metragem = float(input("Entre com a metragem da casa:"))

    if 30 <= metragem < 300:
      metragemP = 60 + (0.3 * metragem)
      print("Será necessário um funcionário para a limpeza")
      print("*" * 100)

'''

Here's the code that works without functions

'''

adcfinal = 0

print("Bem-vindo ao Programa de Serviços de Limpesa do João")
print("*"*100)
print("-"*34,"Menu 1 de 3 - Metragem Limpeza","-"*34)
while True:
    metragem = float(input("Entre com a metragem da casa:"))

  if 30 <= metragem < 300:
    metragemP = 60 + (0.3 * metragem)
    print("Será necessário um funcionário para a limpeza")
    print("*" * 100)

  elif 300 <= metragem < 700:
    metragemP = 120 + (0.5 * metragem)
    print("Seram necessários dois funcionários para a limpeza ")
    print("*" * 100)

  else:
    print("!! Não aceitamos casas com metragem menor que 30m² ou maior que 700m² !! ")
    continue

  while True:
    print("-"*34," Menu 2 de 3 - Tipo de limpesa","-"*34)

    print("B - Básica - Indicada para sujeiras semanais ou quinzenais")
    print("C - Completa (30% a mais) - Indicada para sujeiras antigas e/ou não rotineiras")

    tipo = input("Entre com o tipo de limpeza:")

    if tipo.upper() == "B":
        print("Voçê selecionou limpeza Básica")
        multiplier = 1
        print("*"*100)


    elif tipo.upper() == "C":
        print("Voçê selecionou limpeza COMPLETA")
        multiplier = 1.3
        print("*" * 100)
    else:
        print("Invalido")
        continue

    while True:

        print("-"*34,"Menu 3 de 3 - Adicional de Limpeza","-"*34)
        print("0 - Não desejo mais nada (encerrar)")
        print("1 - Passar 10 peças de roupa - R$ 10,00")
        print('2 - Limpeza de 1 Forno/Micro-ondas - R$12,00')
        print("3 - Limpeza de 1 Geladeira/Freezer - R$20,00")
        adc = int(input("Deseja mais algum adicional?"))

        if adc == 0:
            total = (metragemP * multiplier) + adcfinal
            print("*" * 100)
            print("TOTAL: R$ {:.2f} (metragem: {:.2f} * tipo {:.2f} + adicional: {:.2f})".format(total,metragemP,multiplier,adcfinal))
            print("*" * 100)
            break

        elif adc == 1:
            adcfinal += 10
            continue

        elif adc == 2:
            adcfinal += 12
            continue

        elif adc == 3:
            adcfinal += 20
            continue
    break
break

'''

Here's what I tried:

  1. Check identation
  2. Change the order
  3. Use return (60 + (0.3 * metragem))
  4. Use aliasing at the end ex: metragemP = metragem_valor()
  5. Change the function
  6. start from scratch
  7. delete everything else

Major problem: I don't know what's the problem or what to do. any tips?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
  • Call the function `metragem_valor()` at the bottom of the module under `if __name__ == "__main__":` see https://stackoverflow.com/q/419163 – bad_coder Oct 07 '22 at 22:26

0 Answers0