Exponentiation negative
unknown
python
4 years ago
543 B
30
Indexable
def exponentiation(base_number, exponent):
if exponent == 0:
return 1
elif exponent > 0:
return base_number * exponentiationv(base_number, exponent - 1)
exforstudent= '''define the negexponentiation function that takes as an input a base number and the emponent,
if the exponent is more or equal to 0 the function returns a normal exponentiation, like the one in the exponentiation
function above. In case of a negative exponent the function returns a negative exponentiation
EX = 2^-3 = 1/8 (or 1/2^3)'''Editor is loading...