floor division
Division with the // operator, which rounds the answer down to the next whole number: 7 // 2 is 3.
In more detail
Together with the remainder operator it splits a division into quotient and remainder, as in long division. It rounds towards minus infinity, so -7 // 2 is -4, not -3. With a float operand the result is a whole-valued float, such as 3.0.
Example
7 // 2, 7 % 2 # (3, 1)Related terms
- remainder — What is left over after whole-number division, given by the % operator: 7 % 2 is 1.
- true division — Division with the / operator, which always gives a float, even when the answer is whole: 6 / 3 is 2.0.
- arithmetic operator — A symbol that does arithmetic on numbers: + add, - subtract, * multiply, / divide, // floor divide, % remainder and ** power.
Taught in
- Division, Quotients And Remainders — Hands-on Python: Complete Video Course & Book
- Input, And Numbers Versus Digits — Hands-on Python: Complete Video Course & Book
- The String Format Method — Hands-on Python: Complete Video Course & Book
- Thirty Questions, One Sneaky Print — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Forty Minutes, Thirty Items: How PCEP Is Run — 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
- Twelve Traps, One Shape Each — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Mock, Review And Exam Day — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Sixty Five Minutes, Forty Items: How PCAP Is Run — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Handlers, args, raise And assert — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Exceptions Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep