id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > powerLoop
prev  |  next  |  chance

Write a function power(base, exponent) that returns the value base^exponent, i.e. base * base * base * ... * base, where there are exponent many terms of the product. For example, powerLoop(2,5) = 2^5 = 32 because 2*2*2*2*2 = 32. Do not use the operator **. Instead, use an accumulator and a for loop that runs n times.


powerLoop(2, 3) → 8
powerLoop(4, 0) → 1
powerLoop(3, 3) → 27

...Save, Compile, Run (ctrl-enter)

def powerLoop(a,n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy