id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs112fall2015 > bacteria
prev  |  next  |  chance

Suppose a bacteria colony grows at a rate of 0.1*dt per small fraction dt of an hour. Suppose the initial number of bacteria is p. Create a difference equation to model the number of bacteria B(t) at time t. Write a function bacteria(p, dt, days) that uses your difference equation to compute and return the number of bacteria in the colony after the given number of days. The other parameters, population and dt, are the initial size of the colony and the step size (dt), respectively. Make sure you also know how to modify your code to plot the population size using matplotlib. Your code should cast your final answer to an integer before returning it.


bacteria(100, 0.01, 2) → 12134
bacteria(10, 1, 3) → 10511
bacteria(400, 0.03, 5) → 64134690

...Save, Compile, Run (ctrl-enter)

def bacteria(population, dt, days):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Post-solution available

Copyright Nick Parlante 2017 - privacy