+ 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

13th Apr 2021, 11:35 PM
Peter
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
14th Apr 2021, 12:46 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 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..
1st Jun 2021, 5:21 AM
Rahul Gj
Rahul Gj - avatar
+ 2
Thank you Rik and Loser....Im at preset pretty hopeless ...so far... in the Python Peter
15th Apr 2021, 6:06 PM
Peter
+ 1
Codemurai while humour lightens and brightens the place - it's less helpful in helping with the solution. Nice Joke, btw. 🙂
15th Apr 2021, 2:26 PM
Loser
Loser - avatar
+ 1
Loser I know it is a small joke I will try to help
15th Apr 2021, 3:31 PM
Codemurai
Codemurai - avatar
+ 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.
15th Apr 2021, 6:13 PM
Loser
Loser - avatar
+ 1
Thank you Loser I will order the book
17th Apr 2021, 12:32 PM
Peter
+ 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.
25th Sep 2021, 12:08 PM
AR BLADE
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.
15th Apr 2021, 8:36 AM
Loser
Loser - avatar
0
Hmmmm...... Lot of bacteria Use a Dettol Print("Dettol")
15th Apr 2021, 2:01 PM
Codemurai
Codemurai - avatar
0
For input, just enter the number of hours you would like to calculate. Hours = (input()) print (500*2**int(Hours))
20th Jul 2021, 1:24 PM
Emile
Emile - avatar
0
Thank you for the answer
9th Nov 2021, 6:54 PM
gem
0
thanks rahul raj
19th Dec 2021, 5:38 PM
Rajpoot
0
Hi there, To whom this may help. I got the corrcet answer with this solution. Hope it helps print( 2** 24 * 500)
28th Feb 2022, 6:39 PM
Brent Tyson
Brent Tyson - avatar