All problems
Newton Cooling Value
Problem
Newton's law of cooling gives T(t) = T_a + (T_0 - T_a) * e^(-k*t), where T_a is the ambient temperature and k the cooling constant.
Given t, initial temperature t0, ambient temperature ta, and rate k, return T(t).
Hint
At t = 0 the temperature is t0, and as t grows it approaches the ambient temperature.
Test cases
case 1
in: [0,100,20,0.1]
expected: 100
case 2
in: [10,100,20,0.1]
expected: 49.43035529371539
case 3
in: [5,50,25,0]
expected: 50
case 4
in: [2,30,30,1]
expected: 30
Starter codePython
def newton_cooling(t, t0, ta, k):
# Your code here
pass4 test cases · run your code against them in the editor