-2

Lets just say that I have this python script:

a = 2 ** 10
b = a ** # Code to reverse the process done for a.
print(a) # Prints 1024
print(b) # Should print 2

How do I do this?

miradulo
  • 28,857
  • 6
  • 80
  • 93
Person
  • 379
  • 1
  • 3
  • 15
  • 1
    Possible duplicate of [Is there a short-hand for nth root of x in Python](https://stackoverflow.com/questions/19255120/is-there-a-short-hand-for-nth-root-of-x-in-python) – miradulo Feb 28 '18 at 01:01
  • inverse of 'raise to the power N' is called 'taking the Nth root', for information – Pac0 Feb 28 '18 at 01:02

1 Answers1

3

You would want to find the xth root of the value. To do that you raise the result to the inverse of the power. So, the answer to your question is:

a = 2 ** x
b = a ** (1/x) # Code to reverse the process done for a.
print(a) # Prints 1024
print(b) # Should print 2
BShaps
  • 1,344
  • 7
  • 17