-
Notifications
You must be signed in to change notification settings - Fork 30
Object-oriented
: Add simpler examples, update quiz and exercises
#249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Object-oriented
: Add simpler exercises
Also added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new examples are great. Much more intuitive. Only one change I would make to check the full_name method.
Then things you didn't actually change but it may make sense to rewrite the old exercises more similar to the new examples, e.g. also return the object for better testing and I didn't like the quiz too much, i thought the answers could have been clearer.
…roduce their results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from addressing Example 2's test, I have a comment about the quiz:
Q1: __str__
and __repr__
We should say that "__str__
can be used as __repr__
" because they are technically independent.
Q1: Which statement best describes the relationship between __str__ and __repr__?
1. They are independent methods with no relationship to each other
2. __str__ is used as a fallback when __repr__ is missing
3. __repr__ is used as a fallback when __str__ is missing
And (3) is the correct one.
Q3: @property
I would change the correct one to "@property
creates attributes that act like methods but can be accessed and assigned as regular attributes."
To be able to "set" property attributes, we must user the @attribute.setter
decorator as well, otherwise Python raises an AttributeError
.
Also: why using property restricts the dynamic behavior? We could define or change another attribute on-the-fly:
class Circle:
def __init__(self, radius):
self.radius = radius
@property
def area(self):
self._area = 3.14 * self.radius * self.radius # dynamic, I would say
return self._area
So perhaps rephrase "dynamic" and don't mention attribute setting because we don't talk about setters in this notebook.
It seems there a lot to fix in this notebook, but it's just that's a tricky topic. Thanks for all the fixes, addition, changes @despadam! |
Object-oriented
: Add simpler exercisesObject-oriented
: Add simpler examples, update quiz and exercises
Hey @Snowwpanda & @edoardob90 , thanks for your detailed reviews so far! I finished all changes I wanted to make, so I now ask you for another (hopefully final) review. I deliberately left |
Has been addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, we're good to go! 🚀 👏🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now is the right one! 💯 I let @despadam push the button 😉
* UI revamp WIP * `Object-oriented`: Add simpler examples, update quiz and exercises (#249) * add 2 new examples * finish new examples * finish new examples pt2 * update new examples with docstrings and improved tests * add docstrings * finish docstrings * make sure that class methods are only using the class attributes to produce their results * test that the return value is an instance of a custom class * use closure to check for usage of class attributes * update property section and quiz * Expand docstring description of Exercise 4 * finish updating the exercises * Minor changes * Stupid metadata fix of the ipython notebook * Fixing * Replacing variable l: E741 Ambiguous variable name: `l` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: edoardob90 <edoardob90@gmail.com> Co-authored-by: Snowwpanda <pascal.su@empa.ch> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Revamp UI of AI widgets * Resolve flake8 errors * Fix more UI inconsistencies * Fix test in Object-Oriented Example 4 (#262) * Add __eq__ validation in Example 4 * Add a comment to explain the rationale behind __closure__ testing --------- Co-authored-by: edoardob90 <edoardob90@gmail.com> * Fix errors found in the `input_output` notebook (#258) * Fixing some issues with the input_output notebook and changing some exercies a bit. * Added an exercise to input_output notebook * Added Docstrings to exercises * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Changes for pre-commit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Variable naming consistent in tests. * Reformulation program execution Co-authored-by: Despina Adamopoulou <16343312+despadam@users.noreply.github.com> * Review from despina fixes * Resetting inputfiles after exercises (after writing to file is explained) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * to_bytes function needs byteorder --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Despina Adamopoulou <16343312+despadam@users.noreply.github.com> * Move quizzes to dedicated folder (#263) * move quizes to folder * Rename: quizes -> quiz --------- Co-authored-by: edoardob90 <edoardob90@gmail.com> --------- Co-authored-by: Despina Adamopoulou <16343312+despadam@users.noreply.github.com> Co-authored-by: Snowwpanda <pascal.su@empa.ch> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
As seen in #239, there were no bugs/errors reported for this notebook. So we proceed with just adding a few simpler exercises. More specifically, we add
Examples 1,2,3,4
- one per each theoretical part, so that participants can practice while studying. Then, all exercises of greater difficulty have been moved to the end of the notebook.