From 1caf083b653eab4c3549453f7b69832ac048623a Mon Sep 17 00:00:00 2001 From: j Date: Sun, 2 Apr 2023 08:53:44 +0200 Subject: [PATCH] Update page 'Day 3 homework' --- Day 3 homework.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Day 3 homework.md b/Day 3 homework.md index 82e6d09..3bfb230 100644 --- a/Day 3 homework.md +++ b/Day 3 homework.md @@ -26,7 +26,10 @@ class BoundedInt(): 2. Modify the template to pass test 1, which checks that `int()` called on your class will return the value of `i`. 3. Read this, and the paragraph below it: https://docs.python.org/3/reference/datamodel.html?highlight=__int__#object.__add__ 4. What do you think the types of x and y are? Guess, without checking first. What are they, actually? You can use the debugger's local window to find out. -5. Modify the template to pass test 2, which checks that: +5. Don't forget that you can access the value of a BoundedInt by using either `.i` on it, or `int()`, now that you've passed test 1. +6. Modify the template to pass test 2, which checks that: * Your class implements the + operator. * It throws ValueError when attempting to add two BoundedInts that will exceed the limits. -6. Do the same as 2, but for subtraction. +7. Do the same as 6, but for subtraction, to pass test 3. +8. Modify the template so it also supports adding a regular integer to a BoundedInt, to pass test 4. Note that you can use `isinstance()` to determine the class of a variable. +9. Same as 8, but for subtraction.