Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Arithmetic Operators

DIV and MOD

All topicsPractise exam questions
Knowledge organiser

Arithmetic Operators

301.2b

Use integer division & remainder.

What you need to know

DIV (//) gives the whole-number result of a division, throwing away the remainder. MOD (%) gives just the remainder. Together they are useful for time conversions and digit extraction.

Key points

  • // is integer division (DIV): 17 // 5 → 3
  • % is modulo (MOD): 17 % 5 → 2
  • Useful for converting units, e.g. minutes to hours
  • MOD by 2 checks odd/even: n % 2 == 0 means even

Code examples

DIV and MOD
python
minutes = 135
hours = minutes // 60    # 2
leftover = minutes % 60  # 15
print(hours, "h", leftover, "m")