Skip to content

Room 1 - apply_vaccine_py#7

Open
tlestang wants to merge 1 commit into
mainfrom
apply_vaccine_py
Open

Room 1 - apply_vaccine_py#7
tlestang wants to merge 1 commit into
mainfrom
apply_vaccine_py

Conversation

@tlestang
Copy link
Copy Markdown
Owner

No description provided.

Comment thread snippets/apply_vaccine.py
inject_first_jab(ind)
ndoses = ndoses - 1
else:
raise OutOfDosesException
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what 'raise' does. How is it different from 'print'?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using raise allows me to do stuff like

try:
   # something
except OutOfDosesException:
   # do something else

Comment thread snippets/apply_vaccine.py
inject_second_jab(ind)
else:
inject_first_jab(ind)
ndoses = ndoses - 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should be indented as now ndoses gets reduced by 1 regardless of what happens in the if

Comment thread snippets/apply_vaccine.py
def apply_vaccine_to_population(population, ndoses, threshold_age):
for ind in population:
if ndoses > 0:
if (ind["age"] > threshold_age or ind["isAtRisk"]):
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (isEligible(ind)):
   # then do something

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants