def power, problem when raising power to decimals

skanemupp at skanemupp at
Wed Apr 16 22:19:13 CEST 2008

how do i solve power(5,1.3)?

def power(nbr, po):
    if po==0:
        return 1
    if po>0:
        return nbr*power(nbr, po-1)
    if po<0:
        return 1/power(nbr, -1*po)

also i found a link which states 0^0 isnt 1 even though every
calculator ive tried says it is.
it doesnt say what it is but i presume 0 then.
but it seems the dude is wrong and it is 1?

dont run the code with decimals, it will never leave the function, u
have to restart the shell(if using the standard python ide)

More information about the Python-list mailing list