Part 4 · Section 05

Project 2

Time to put the special methods to work on a single, realistic class. In modular arithmetic, numbers “wrap around” a modulus, the way clock hours wrap around 12: 14 ≡ 2 (mod 12). In this project you’ll write a Mod class whose instances behave like numbers in that world: Mod(8, 3) is the same as Mod(2, 3), it equals the plain integer 5, and Mod(2, 3) + 2 is Mod(1, 3).

This project practices:

Lectures

  1. 01Project 2 - Solution✓

Practice: quiz & exercises

7 quiz questions · 4 coding exercises

Go to practice →