# Bacteria problem 5.2

Hi. Total beginner here. The bacteria problem formula is; 500* 2 ** N . N goes sequentially up to 30 So I coded: (500 * 2 ** N), N = range (30) I looked up the N= range () on Google but was not correct. Would appreciate guidance. Thank you

4/13/2021 11:35:03 PM

Peter11 Answers

New AnswerI think this is what you need for N in range(30): print(500 *2 **N) create a range, then apply your formula where N is the power being generated by the range. The print function will show the result of each iteration

Codemurai while humour lightens and brightens the place - it's less helpful in helping with the solution. Nice Joke, btw. ðŸ™‚

@Peter You can try "Programming with Python for Absolute Beginners - 'Mike Dawson' ". Really, Good one. It's the same book I refer to my students. OR you can try programiz.com, really a great reference. This place is just for practice, revision and doubt-solving.

This will help you and it's the right answer!! N=24 print(500*2**N) SIMPLE..!! No need to use for loop for this..

It is simple to done . First step - what has given to us. Second - write bacteria =500, n=24. Third - use (500*2**n). That's it and run the code you get the result.

N = 30 for i in range(N): i = i + 1 print(500 * 2 ** i) range function works with 'for' loops, not alone.. you would require to have a variable, in this case 'i', that will intake the value N gives out from '0' till 'N'. As the value for 'i' starts from 0, we have to have statement/expression that will change it's value from 0 to 1, (hence, the statement - i = i + 1) inorder to get the desired output.

For input, just enter the number of hours you would like to calculate. Hours = (input()) print (500*2**int(Hours))