17th Feb 2022, 7:07 PM
Eric Vazquez
2 Answers
+ 2
def raise_to_power(base_num, pow_num): result = 1 #this loop runs pow_num=2 times, and base_num=3 for index in range(pow_num): result = result * base_num #iteration 1 : result = 1*3 = 3 #iteration 2 : result = 3*3 = 9 return result #returns 9 print(raise_to_power(3,2)) #calling function with 3,2 arguments edit: if you don't know, : yes, it is user implemented power of function. equal to using simply print( 3**2 ) ** is power of operator in python..
17th Feb 2022, 7:20 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
It is a complicated way of doing this: print ( 3 ** 2 ) print ( 2 ** 4 ) print ( 5 ** 5 )
17th Feb 2022, 7:36 PM
Paul
Paul - avatar