curriculum/challenges/english/blocks/daily-coding-challenges-python/68c1a929005bf54d342aa8d6.md
For the fifth day of Space Week, you will calculate the "Goldilocks zone" of a star - the region around a star where conditions are "just right" for liquid water to exist.
Given the mass of a star, return an array with the start and end distances of its Goldilocks Zone in Astronomical Units.
To calculate the Goldilocks Zone:
For example, given 1 as a mass, return [0.95, 1.37].
goldilocks_zone(1) should return [0.95, 1.37].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(goldilocks_zone(1), [0.95, 1.37])`)
}})
goldilocks_zone(0.5) should return [0.28, 0.41].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(goldilocks_zone(0.5), [0.28, 0.41])`)
}})
goldilocks_zone(6) should return [21.85, 31.51].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(goldilocks_zone(6), [21.85, 31.51])`)
}})
goldilocks_zone(3.7) should return [9.38, 13.52].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(goldilocks_zone(3.7), [9.38, 13.52])`)
}})
goldilocks_zone(20) should return [179.69, 259.13].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(goldilocks_zone(20), [179.69, 259.13])`)
}})
def goldilocks_zone(mass):
return mass
import math
def goldilocks_zone(mass):
luminosity = mass ** 3.5
start = 0.95 * math.sqrt(luminosity)
end = 1.37 * math.sqrt(luminosity)
return [round(start, 2), round(end, 2)]