If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Challenge: 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.

Code editor

Code files

Output