0

Having trouble

Specific Question Did you know that there are more bacteria cells in your body than cells that make up your body? Weird! A bacteria culture starts with 500 bacteria and doubles in size every hour. Which means, after 1 hour the number of bacteria is 1000, after 2 hours - 2000, and so on. Let’s calculate and output the number of bacteria that will be in the culture after 24 hours. Not sure what to multiply.

10th May 2021, 12:22 PM
Jarred Gooch
Jarred Gooch - avatar
21 Antworten
+ 3
always read the task carefully. sometimes there you can find a hint of its solution
10th May 2021, 5:44 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
Finally after some research solved it. Thank you so much for your help what i was doing wrong was print (500*2^24) when in fact code for 2^24 is written out 2**24. So the answer was print (500*2**24)
10th May 2021, 3:21 PM
Jarred Gooch
Jarred Gooch - avatar
+ 2
Thank you so much, id still be stuck if you didnt help
10th May 2021, 5:21 PM
Jarred Gooch
Jarred Gooch - avatar
+ 1
Or you can use pow function: pow(3, 2) # output 9 -> 3² pow(10, 3) # output 1000 -> 10³
10th May 2021, 5:17 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
#Soution - bact = 500 for num in range(1,25): bact = bact*2 print(bact)
6th Oct 2021, 10:13 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
+ 1
THANK YOU ALL
16th Nov 2021, 6:23 AM
Jahongir Sirojiddinov
Jahongir Sirojiddinov - avatar
0
What language? Simply you can create a loop of 24 hr And set the following logic Initial = 500 Inital = Intial * 2 ( mutilation of initial by 2 after updating inital for 24 times )
10th May 2021, 12:31 PM
Ayush Kumar
Ayush Kumar - avatar
0
Hi! Can you show us your code attempt? Thx!
10th May 2021, 12:33 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
I am entirely new to code, the language is python.
10th May 2021, 12:39 PM
Jarred Gooch
Jarred Gooch - avatar
0
make a try and write at least some code. how can we help you without seeing the code?
10th May 2021, 12:40 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
in the task itself, at the bottom, in the yellow field, you are even given a hint on which formula to use for this. just write it using python and display the result on the screen. where did you stumble?
10th May 2021, 12:48 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
The example given is (500 *2n) in python i wrote out print (500*2) and i get the results to 500*2 i dont know where to go from here. Im not sure what exactly they want me to multiply.
10th May 2021, 12:54 PM
Jarred Gooch
Jarred Gooch - avatar
0
500*2 -> this is the progress of bacterial growth in one hour. and in the task, how many hours are you asked to count the bacteria?
10th May 2021, 12:56 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
24 hours
10th May 2021, 1:28 PM
Jarred Gooch
Jarred Gooch - avatar
0
Right! And now insert this number to given formula: 500*2N, where N - number of hours. two to the power of the number of hours
10th May 2021, 2:08 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
So 500 times 2 to the 24 power
10th May 2021, 3:05 PM
Jarred Gooch
Jarred Gooch - avatar
0
yes, you just had to repeat the lesson of exponentiation and remember how this operator looks in python
10th May 2021, 4:37 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Did you know that there are more bacteria cells in your body than cells that make up your body? Weird! A bacteria culture starts with 500 bacteria and doubles in size every hour. Which means, after 1 hour the number of bacteria is 1000, after 2 hours - 2000, and so on. Let’s calculate and output the number of bacteria that will be in the culture after 24 hours.
17th Aug 2021, 2:03 AM
Shoaib Junaid khan
Shoaib Junaid khan - avatar
- 1
its too easy use this u can get your output print(500*2**24)
6th Oct 2021, 12:32 PM
Vandana
- 1
bact = 500 for num in range(1,25): bact = bact*2 print(bact)
4th Dec 2021, 6:03 PM
Md. Rakibul Islam
Md. Rakibul Islam - avatar