DEV Community

loading...

Discussion on: Daily Challenge #61 - Evolution Rate

Collapse
devparkk profile image
Dev Prakash
def getEvolutionratemessage (before , after) :
    try :
        evolution = (after - before ) / before * 100 
    except ZeroDivisionError : 
        return "can't divide by zero " 

    if evolution > 0 :
        statement = f"A Positive evolution of {round(evolution)}%"
    elif evolution < 0:
        statement = f"A Negative evolution of {round(evolution)}%"
    else :
        statement = f"No evolution"
    return statement 

print (getEvolutionratemessage(95.12 , 66.84))