Update page 'Day 3 homework'
+1
-1
@@ -25,7 +25,7 @@ class BoundedInt():
|
|||||||
1. Read this: https://docs.python.org/3/reference/datamodel.html?highlight=__int__#object.__int__
|
1. Read this: https://docs.python.org/3/reference/datamodel.html?highlight=__int__#object.__int__
|
||||||
2. Modify the template to pass test 1, which checks that `int()` called on your class will return the value of `i`.
|
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__
|
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.
|
4. In that reading material, there's a sentence that starts with "For instance, to evaluate the expression x + y, "... 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. 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.
|
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:
|
6. Modify the template to pass test 2, which checks that:
|
||||||
* Your class implements the + operator.
|
* Your class implements the + operator.
|
||||||
|
|||||||
Reference in New Issue
Block a user