unary minus
The minus sign in front of a single value, as in -5 or -x, which negates it.
In more detail
It binds tighter than * and / but more loosely than **, so -2 ** 2 is -4, not 4. Write (-2) ** 2 when you mean the square of minus two.
Related terms
- arithmetic operator — A symbol that does arithmetic on numbers: + add, - subtract, * multiply, / divide, // floor divide, % remainder and ** power.
- operator precedence — The rules that decide which operators in an expression are applied first, such as multiplication before addition.
Taught in
- Integer Arithmetic And Precedence — Hands-on Python: Complete Video Course & Book
- Division, Quotients And Remainders — Hands-on Python: Complete Video Course & Book
- Lists, Range And The For Loop — Hands-on Python: Complete Video Course & Book
- Debugging: print, breakpoint, and the debugger — Hands-on Python: Complete Video Course & Book
- Thirty Questions, One Sneaky Print — 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
- Fundamentals Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Twelve Traps, One Shape Each — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- String Methods The Exam Picks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Inheritance, super() And Polymorphism — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep