+ 1
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
14 Answers
+ 6
I 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
+ 4
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..
+ 2
Thank you Rik and Loser....Im at preset pretty hopeless ...so far... in the Python
Peter
+ 1
Codemurai while humour lightens and brightens the place - it's less helpful in helping with the solution. Nice Joke, btw. 🙂
+ 1
Loser
I know it is a small joke I will try to help
+ 1
@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.
+ 1
Thank you Loser I will order the book
+ 1
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.
0
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.
0
Hmmmm......
Lot of bacteria
Use a Dettol
Print("Dettol")
0
For input, just enter the number of hours you would like to calculate.
Hours = (input())
print (500*2**int(Hours))
0
Thank you for the answer
0
thanks rahul raj
0
Hi there,
To whom this may help.
I got the corrcet answer with this solution. Hope it helps
print( 2** 24 * 500)