Root account error Math.sqrt with multiplication and division

Asked

Viewed 83 times

2

I’m making an interface with buttons in Python, but after writing the account was error... I tried to redo and is giving indentation error. What I need is the code is correct?

Follows 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"

2 answers

1


I managed to solve my problem... I separated the accounts and gave new names for the variables,.

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"

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 identation is part of the syntax, IE, the programmer is required to ident the code so that it has the expected meaning.

In your code you start a new indentation without need, maybe by mistake, go back these 3 lines to the initial indentation and try to run 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 +- like this, if you are still giving error, it is probably another error message.

  • Hi Gabriel, still giving the error message, can not calculate... I fixed the identation and still gives error.... I do not know what else to do

Browser other questions tagged

You are not signed in. Login or sign up in order to post.