Python arithmetic: //, % and **: Class 11 practice
In Python, / always gives a float, // is floor division (rounds down, even for negatives), % gives the remainder with the sign of the divisor, and ** is power (evaluated right to left). Read the method, follow the three worked examples, then try the six questions.
What you should know first
- Integer division
The idea behind python arithmetic: //, % and **
In Python, / always gives a float, // is floor division (rounds down, even for negatives), % gives the remainder with the sign of the divisor, and ** is power (evaluated right to left). Precedence: ** then * / // % then + −.
Step-by-step method
- Apply ** first (right to left).
- Then *, /, //, % left to right.
- Then + and −.
Worked example 1 (Basic)
What does Python print for: print(20 // 8, 20 % 8)?
- 20 // 8 = floor(2.5) = 2
- 20 % 8 = 20 − 8 × 2 = 4
- Answer: 2 4
Worked example 2 (Standard)
What does Python print for: print(2 ** 3 ** 2)?
- ** is right-associative: 3 ** 2 = 9
- 2 ** 9 = 512
- Answer: 512
Worked example 3 (Challenge)
What does Python print for: print(-28 // 9, -28 % 9)?
- -28 // 9 = floor(-3.11) = -4
- -28 % 9 = -28 − 9 × -4 = 8
- Answer: -4 8
Common mistakes and misconceptions
- Thinking −7 // 2 is −3 (it is −4)
- Evaluating 2 ** 3 ** 2 left to right
Practice questions
- (Basic) What does Python print for: print(22 // 8, 22 % 8)?
- (Basic) What does Python print for: print(23 // 8, 23 % 8)?
- (Standard) What does Python print for: print(2 ** 2 ** 2)?
- (Standard) What does Python print for: print(2 ** 2 ** 3)?
- (Challenge) What does Python print for: print(-27 // 6, -27 % 6)?
- (Challenge) What does Python print for: print(-53 // 8, -53 % 8)?
Answer key with full working
- Q1: 22 // 8 = floor(2.75) = 2 → 22 % 8 = 22 − 8 × 2 = 6 → Answer: 2 6
- Q2: 23 // 8 = floor(2.88) = 2 → 23 % 8 = 23 − 8 × 2 = 7 → Answer: 2 7
- Q3: ** is right-associative: 2 ** 2 = 4 → 2 ** 4 = 16 → Answer: 16
- Q4: ** is right-associative: 2 ** 3 = 8 → 2 ** 8 = 256 → Answer: 256
- Q5: -27 // 6 = floor(-4.5) = -5 → -27 % 6 = -27 − 6 × -5 = 3 → Answer: -5 3
- Q6: -53 // 8 = floor(-6.63) = -7 → -53 % 8 = -53 − 8 × -7 = 3 → Answer: -7 3
Syllabus note
This skill is listed under "Python Fundamentals" for Class 11 in the NCERT/CBSE books. ICSE, IGCSE, IB and state boards may teach it in a different chapter or year.
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Related practice and notes
Frequently asked questions
Which chapter is python arithmetic: //, % and ** in?
"Python Fundamentals", Class 11 Computer Science (NCERT/CBSE). Other boards may place it differently.
How were the answers checked?
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.