** Power
Last updated: 2026-09-22
** Power
** computes a raised to the power b.
| Category | Operators |
|---|---|
| Kind | Operator |
| Python Version | all |
📝 Syntax
a ** b
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
1024
3.0
0.5
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does 2 ** 3 ** 2 equal?
AIt equals 512, because `**` is right-associative: `2 ** (3 ** 2) = 2 ** 9`. To express `(2**3)**2 = 64`, you must add parentheses explicitly.
QWhat is the difference between ** and pow()?
AThe results are essentially the same. `pow` also has an optional three-argument form `pow(a, b, m)` that computes `a**b % m` more efficiently, often used for modular exponentiation in cryptography.
QHow are negative exponents, fractional exponents, and negative bases computed?
A`2 ** -1` gives `0.5`, and `9 ** 0.5` gives `3.0`. A negative base with a fractional exponent yields a complex number, e.g. `(-8) ** (1/3)` returns a complex result.
QWhat does -2 ** 2 equal?
AIt equals -4. Because `**` binds tighter than the unary minus on its left, `-2 ** 2` parses as `-(2**2)`. To compute `(-2)**2 = 4` you must add parentheses.