Error in root account math.sqrt with multiplication and division

2

I am making an interface with buttons in Python, but after typing the account it gave error ... I tried to redo and it is giving indentation error. What do I need is the code correct?

Follow the code!

try:
    DEMANDA=float(self.DEMANDA.get())
    CUSTOAQUISAO=float(self.CUSTOAQUISAO.get())
    CUSTOUNITARIO =float(self.CUSTOUNITARIO.get())
    TAXAARMAZENAGEM = float(self.FRETE.get())
    Qe=(math.sqrt((2*(DEMANDA*CUSTOAQUISAO)/(CUSTOUNITARIO/TAXAARMAZENAGEM)))
        s="O Lote Econômico é composto por         peças  "
        s=s+str(Qe)
        print (Qe)
except:
    s="Erro"
    
asked by anonymous 16.06.2017 / 10:08

2 answers

1

I was able to solve my problem ... I separated the accounts and gave new names to the variables, continue to help those who need them.

try:
    VAR1=float(self.VAR1.get())
    VAR2=float(self.VAR2.get())
    VAR3=float(self.VAR3.get())
    VAR4=float(self.VAR4.get())
    VAR5=(2*(VAR1*VAR2))
    VAR6=(VAR3*VAR4)
    VAR7=(math.sqrt(VAR5/VAR6))

    s="O Lote Econômico é composto por peças  "
    s=s+str(round(VAR7))+"peças"

except:
    s="Erro"
    
18.06.2017 / 21:14
1
Qe=(math.sqrt((2*(DEMANDA*CUSTOAQUISAO)/(CUSTOUNITARIO/TAXAARMAZENAGEM)))
        s="O Lote Econômico é composto por         peças  " # identado errado a partir daqui
        s=s+str(Qe)
        print (Qe)

Python is a language where indentation is part of the syntax, ie the programmer is required to indent the code so that it has the expected meaning.

In your code you start a new indentation without need, perhaps by mistake, turn these 3 lines to the initial indentation and try to execute it again.

    try:
        DEMANDA=float(self.DEMANDA.get())
        CUSTOAQUISAO=float(self.CUSTOAQUISAO.get())
        CUSTOUNITARIO =float(self.CUSTOUNITARIO.get())
        TAXAARMAZENAGEM = float(self.FRETE.get())
        Qe=(math.sqrt((2*(DEMANDA*CUSTOAQUISAO)/(CUSTOUNITARIO/TAXAARMAZENAGEM)))
        s="O Lote Econômico é composto por         peças  "
        s=s+str(Qe)
        print (Qe)
    except:
        s="Erro"

The result should be + - so if you still have an error, it will probably be another error message.

    
16.06.2017 / 13:06