Skip to content

Conversation

@ike-agu
Copy link

@ike-agu ike-agu commented Dec 28, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR contains my sprint 5 prep exercises:

  • Why we use types
  • Type checking with mypy
  • Classes and Objects
  • Methods
  • Data classes
  • Generics
  • Type guided refactoring
  • Enums
  • Inheritance

@github-actions

This comment has been minimized.

@ike-agu ike-agu changed the title London | SDC-Nov-2025| Ikenna Agulobi | Sprint-5| Prep exercise python London | SDC-Nov-2025| Ikenna Agulobi | Sprint 5| Prep exercise python Dec 28, 2025
@ike-agu ike-agu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 28, 2025
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jan 14, 2026
Copy link

@LonMcGregor LonMcGregor left a 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

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?

Copy link
Author

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.

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?

Copy link
Author

@ike-agu ike-agu Jan 20, 2026

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)

def print_family_tree(person: Person) -> None:
print(person.name)
for child in person.children:
print(f"- {child.name} ({child.age})")

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?

Copy link
Author

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

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)."

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

Copy link
Author

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 LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 14, 2026
@ike-agu
Copy link
Author

ike-agu commented Jan 20, 2026

@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.

@ike-agu ike-agu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jan 20, 2026
Copy link

@LonMcGregor LonMcGregor left a 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 LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jan 20, 2026
@ike-agu
Copy link
Author

ike-agu commented Jan 20, 2026

@LonMcGregor Thank you for taking the time to review my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants