Course: Intro to computer science - Python > Unit 3
Lesson 4: Loop control flowChallenge: Infectious diseases
Instructions
Step 1
Model virus recovery
Jamaal wants to predict the spread of a new virus in the area’s chicken population. An infected chicken can spread the virus to other chickens it comes in close contact with. Chickens become immune and cannot catch the virus again once they have been infected.
Jamaal built a simulation to model the spread, but chickens don’t stay infected forever. He needs to add a step that models their recovery.
- Call the
virus.recover()
function to model how many infected chickens recover each day. - Subtract any newly recovered chickens from the
infected
count.
Make sure that the print statement inside the loop runs after the infected count has been updated.
The virus.recover()
function takes the number of infected chickens as an argument and returns how many of those chickens recovered on a given day.