程式碼因為你用圖片我就懶得改了
(貼程式碼可參考:https://ithelp.ithome.com.tw/markdown#mk_fenced )
請問是這樣嗎,謝謝您的幫助,希望可以再次幫忙解答!
import math
t=30
T=0
x= float(input('輸入大腸桿菌初始數量:'))
if x >= 600:
print('Need to change the water now.')
elif x < 600:
while x < 600:
x=x * math.pow(2,(T/t))
print('T=',T)
print('x=',x)
T=T+1
print()
else:
print('after ',T-1,' minutes needs to change the water.')```
跟我想的不同,不過我人在外面,要晚點了
如果只照你原本程式碼去修改
應該是 x 值那邊
import math
t = 30
T = 0
x = float(input('輸入大腸桿菌初始數量:'))
if x >= 600:
print('Need to change the water now.')
elif x < 600:
while x * math.pow(2, (T/t)) < 600:
T = T+1
else:
print('after ', T-1, ' minutes needs to change the water.')
至於我的想法是直接用對數去計算
import math
t = 30
x = float(input('輸入大腸桿菌初始數量:'))
if x >= 600:
print('Need to change the water now.')
elif x < 600:
T = math.floor(30 * math.log(600 / x, 2))
print('after ', T, ' minutes needs to change the water.')