Python Challenges: Check if an integer is the power of another integer
Python Challenges - 1: Exercise-5 with Solution
Write a Python program to check if an integer is the power of another integer.
Explanation:
Sample Solution:
Python Code:
def is_Power(x, y):
while (x%y == 0):
x = x / y
return x == 1
print(is_Power(16, 2))
print(is_Power(12, 2))
print(is_Power(81, 3))
Sample Output:
True False True
Flowchart:
Python Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Python program to check if a number is a perfect square.
Next: Write a Python program to check if a number is a power of a given base.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/challenges/1/python-challenges-1-exercise-5.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics