title: how to check if a number is a power of base b?
body: <p>In python, how can you check if a number n is an exact power of base b?</p>
  
  <p>Note: it needs to be generalized to any base which is given as a parameter.</p>
  
  <p>Here is what I got:</p>
  
  <p>Assume n and base are integers > 0.</p>
  
  <pre><code>import math
  def is_power(n,base):
      return math.log(n,base) == base**n
  </code></pre>