-
-
Notifications
You must be signed in to change notification settings - Fork 21
London | 25-SDC-July | Fatma Arslantas | Sprint 4 | Prep exercises #55
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
base: main
Are you sure you want to change the base?
Conversation
…uper() and method overriding
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
LonMcGregor
left a comment
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.
Good start on this sprint's tasks, I have spotted a few areas where you could improve code further
| return number * 3 | ||
|
|
||
| print(double1(10)) | ||
| # When you check the function name, it doesn’t fit what we have to expect. |
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.
Can you suggest a better name?
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.
A better name would be triple, since it multiplies by 3. I’ve added a short comment in the code. Thanks 🙏
|
|
||
| # I learned that a class defines what attributes each object will have. | ||
| # Mypy can check if I try to access an attribute that doesn't exist. | ||
| # It helps to avoid mistakes like typing person.addres instead of person.address. |
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.
In this case, is there a difference between person.addres and person.address?
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.
Yes, there is.
person.address would work only if the Person class actually had an attribute called address, but person.addres (with the typo) doesn’t exist. So mypy can catch that before running the code.
generics.py
Outdated
| @dataclass(frozen=True) | ||
| class Person: | ||
| name: str | ||
| age: int |
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.
Can you solve this in a way that it always prints the current age, rather than hard-coding a specific age?
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.
Yes, we can solve this by calculating the age based on the birth year.
I added this feature to my code, so now the age is always updated automatically according to the current year.
Thank you! 🙌
|
Hi @LonMcGregor, |
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Good work updating this, you're done with this task now |
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Thank you @LonMcGregor 🌸 |
Learners, PR Template
Self checklist
Changelist
This PR includes all the exercises from the “03 Prep Exercises” section of the Decomposition Sprint.
Each exercise is completed in a separate Python file with type annotations and learning notes.
Questions
I don’t have any questions. Thank you.