# Python | sympy.perfect_power() method

• Last Updated : 05 Sep, 2019

With the help of sympy.perfect_power() method, we can find two integers b and e such that be is equal to the given number n.

Syntax:
perfect_power(n)

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Parameter:
n – It denotes an integer.

Returns:
Returns a tuple of integers (b, e) such that be == n.

Example #1:

 `# import perfect_power() method from sympy``from` `sympy ``import` `perfect_power`` ` `n ``=` `64`` ` `# Use perfect_power() method ``b, e ``=` `perfect_power(n) ``     ` `print``(``"n = {}"``.``format``(n))``print``(``"b = {} and e = {}."``.``format``(b, e))``print``(``"{}^{} == {}"``.``format``(b, e, n)) `

Output:

```n = 64
b = 2 and e = 6.
2^6 == 64
```

Example #2:

 `# import perfect_power() method from sympy``from` `sympy ``import` `perfect_power`` ` `n ``=` `64`` ` `# Use perfect_power() method ``b, e ``=` `perfect_power(n, big ``=` `False``) ``     ` `print``(``"n = {}"``.``format``(n))``print``(``"b = {} and e = {}."``.``format``(b, e))``print``(``"{}^{} == {}"``.``format``(b, e, n)) `

Output:

```n = 64
b = 8 and e = 2.
8^2 == 64
```

My Personal Notes arrow_drop_up