-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | SDC-Nov-2025| Ikenna Agulobi | Sprint 5| Prep exercise python #312
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
…t it does report and error
This comment has been minimized.
This comment has been minimized.
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.
Very good work on these tasks, there are some areas where you could improve further
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.
Has this file passed the mypy type checker?
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.
I've added type annotations and fix the bugs to ensure the file passes mypy type checker.
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 describe the difference and any dis/advantage of using a class method vs a function?
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 function is standalone code with its own behaviour, while a class method is code whose behaviour belongs to an object or class and operates on its internal state.
------Advantages of using methods: ---------
• Ease of documentation and discoverability
Attaching behaviour to a type makes it easier to find and understand all operations related to that type. For example, methods on str or Person group related functionality together, rather than scattering it across separate functions.
• Encapsulation
Methods hide the internal representation of a type. If the implementation of Person changes (e.g. storing a date of birth instead of an age), the code that uses Person does not need to change, and it is clearer which methods may need updating internally.
• Improved readability
Methods read like natural language and make code easier to understand e.g is_adult(Imran)
prep_exercise/6_generics.py
Outdated
| def print_family_tree(person: Person) -> None: | ||
| print(person.name) | ||
| for child in person.children: | ||
| print(f"- {child.name} ({child.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.
Can this print grandchildren recursively?
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.
I've now fix my code and family tree prints children recursively. Thank you for your review and feedback
prep_exercise/8_enums.py
Outdated
| if best_os != person.preferred_operating_system and best_count > preferred_count: | ||
| print( | ||
| f"If you are willing to accept {best_os.value} instead," | ||
| f"You're more likely to get a laptop. {best_count} available)." |
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.
I think you have an extra bracket here you dont need
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.
Thanks for catching that. I've now fixed the output message formatting by removing the extra parenthesis.
|
@LonMcGregor ,Thank you for taking the time to review my PR and providing helpful feedbacks. I'v fixed the changes you pointed out. When you will be available, could you take another look. |
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 work on these tasks, it is complete now
|
@LonMcGregor Thank you for taking the time to review my PR. |
Learners, PR Template
Self checklist
Changelist
This PR contains my sprint 5 prep exercises: