Pair work Ch 4.2–4.3
- Due Feb 18, 2022 by 9:50am
- Points 1
- Available after Feb 18, 2022 at 9am
Problem 1
This is based on Problem 4.3.7 in the book.
Vampires can each convert v
people a day into vampires. However, there is a band of vampire hunters that can kill k
vampires per day. If a coven of vampires starts with vampires
members, how many days before a town with a population of people
becomes a town with no humans left in it? Write a function
vampireApocalypse(v, k, vampires, people)
that returns the answer to this question. The function should also plot the number of days (x-axis) versus the population of people and the population of vampires (y-axis). You'll need a separate pyplot.plot
statement for each of the two populations. Give each a label, e.g.,: pyplot.plot(days, people, label='People')
. You'll also need to tell pyplot to show the legend: pyplot.legend()
.
Try your function with this call:
vampireApocalypse(.5, 1, 5, 40000)