-
-
Notifications
You must be signed in to change notification settings - Fork 22
ZA | 25-SDC-July | Luke Manyamazi | Sprint 4 | Prep Exercises #41
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
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
|
|
||
| print(double("22")) | ||
|
|
||
| # I somehow expected it to return this answer, because the string "22" doubled is "2222" No newline at end of file |
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.
Is this behaviour consistent for all inputs (think about possible types of input). Are there any changes you would suggest making to prevent bugs from happening if this function were used incorrectly?
|
|
||
| imran = Person("Imran", 22, "Ubuntu") | ||
| print(imran.name) | ||
| # print(imran.address) # Person has no address attribute |
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.
Could you suggest a change that would fix this error?
| self.preferred_operating_system = preferred_operating_system | ||
|
|
||
| @property | ||
| def age(self) -> 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.
What is a benefit or drawback of writing a function this way?
| class Person: | ||
| name: str | ||
| children: List["Person"] | ||
| 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?
Learners, PR Template
Self checklist
Changelist
Completed all the Python Prep Exercises
Questions
None