DEV Community

loading...

Discussion on: Daily Challenge #61 - Evolution Rate

Collapse
matrossuch profile image
Mat-R-Such

python

def getEvolutionRateMessage(before,after):
    if before == 0 and after == 0:  return "No evolution."
    evolution = after * 100 if before == 0 else  before * 100 if after == 0 else round(((after-before) / before)*100)
    return "A positive evolution of "+str(int(evolution))+'%' if before<after else "A negative evolution of "+str(int(evolution*-1) if evolution <0 else int(evolution))+'%' if before > after else "No evolution."