Percentage in the result

Asked

Viewed 574 times

2

I am making a menu in Python and I need the result of an account to appear in percentage.... O Tmar has value 2 and Tcliclo has value 7 being the result: 0.29 however I can’t place it at 29%. Could anyone help me? Thank you

def Calc3 (self,event):

    try:
        TMAR=float(self.TMAR.get())
        TCICLO=float(self.TCICLO.get())
        Result3=((TMAR/TCICLO)*100)
        s="O Indíce de Rotatividade é de   "
        s=s+str(Result3)
       # print (CTP)
    except:
        s="Erro"
    self.txtCALC3['text']=s
    self.TMAR.delete(0, 'end')
    self.TCICLO.delete(0, 'end')
  • 1

    I did not understand what the doubt is. What should happen and what actually happens?

1 answer

4


The code is correct. See working on Ideone.

For rounding the result, you can use the round(), in this way:

s+=str(round(Result3))+"%"

And to write you the result:

print (s) #Normalmente.
  • Thank you very much Francisco!!!! Now appeared the 29% Thank you

Browser other questions tagged

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