0
Anyone explain me the "Cell growth" solving?
Imagine you are a scientist looking at a new type of cell under the microscope. This type of cell divides itself into 2 daughter cells every 24 hours, meaning that the cell population duplicates every day. Complete the code to take the initial cell population and the number of days you are observing the cells to calculate the cell population at the end of each day in the following format My code: # take the initial cell population as input cells = int(input()) # take the number of days as input days = int(input()) # initialize the day counter counter = 1 #complete the while loop while days >= 0: print (days) days -= 1 # Daily message print("Day " + str(counter) + ": " +str(cells)) counter = 1
2 Respuestas
0
Bronyth, there are a few issues in your code that I would like to point out:
1. Your loop condition is ```while days >= 0``` This will run one extra time (including day 0), and it reduces days instead of using a separate counter. You will end up making 2 cells out of 1 in 0 days if the user enters 0 as rhe number of days.
2. Indenting ```counter = 1``` inside the loop resets the counter every time, so the output always says "Day 1".
3. And, most importantly, you're printing the same population every day instead of doubling it. You are not updating the value of ```cells```
0
You can have a look at this code:
https://sololearn.com/compiler-playground/cKICGaVqmyHv/?ref=app
# By the way, it's a super slow bacteria if it is duplicating its population every 24 hours! XD