exponentiation
Raising a number to a power, written with two stars in Python: 2 ** 10 is 1024.
In more detail
A fractional exponent gives a root, so 9 ** 0.5 is 3.0, the square root. ** binds more tightly than unary minus and works from right to left, so 2 ** 3 ** 2 is 2 ** 9. pow(x, y) does the same.
Example
2 ** 0.5 # 1.4142135623730951Related terms
- arithmetic operator — A symbol that does arithmetic on numbers: + add, - subtract, * multiply, / divide, // floor divide, % remainder and ** power.
- square root — The number that multiplied by itself gives a given number, found in Python with math.sqrt(x) or x ** 0.5.
- operator precedence — The rules that decide which operators in an expression are applied first, such as multiplication before addition.
Taught in
- Floats, Division And Mixed Types — Hands-on Python: Complete Video Course & Book
- Exponents, Roots And Float Formats — Hands-on Python: Complete Video Course & Book
- Chapter One In One Sitting — Hands-on Python: Complete Video Course & Book
- Thirty Questions, One Sneaky Print — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Literals, Names And Four Number Bases — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Operators And Who Binds First — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Print, Input And The Casts Between — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Fundamentals Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep