Percentage in result

2

I am making a menu in Python and I need the result of an account to appear in percentage .... The Tmar has value 2 and Tcliclo has a value of 7 being the result: 0.29, it by 29%. Could someone 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')
    
asked by anonymous 15.06.2017 / 05:31

1 answer

4

The code is correct. See working at Ideone .

For rounding up the result, you can use round() , like this:

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

And to write the result:

print (s) #Normalmente.
    
15.06.2017 / 05:56