2.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68c1a929005bf54d342aa8d2 | Challenge 55: Space Week Day 1: Stellar Classification | 29 | challenge-55 |
--description--
October 4th marks the beginning of World Space Week. The next seven days will bring you astronomy-themed coding challenges.
For today's challenge, you are given the surface temperature of a star in Kelvin (K) and need to determine its stellar classification based on the following ranges:
-
"O": 30,000 K or higher -
"B": 10,000 K - 29,999 K -
"A": 7,500 K - 9,999 K -
"F": 6,000 K - 7,499 K -
"G": 5,200 K - 5,999 K -
"K": 3,700 K - 5,199 K -
"M": 0 K - 3,699 K -
Return the classification of the given star.
--hints--
classification(5778) should return "G".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(5778), "G")`)
}})
classification(2400) should return "M".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(2400), "M")`)
}})
classification(9999) should return "A".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(9999), "A")`)
}})
classification(3700) should return "K".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(3700), "K")`)
}})
classification(3699) should return "M".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(3699), "M")`)
}})
classification(210000) should return "O".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(210000), "O")`)
}})
classification(6000) should return "F".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(6000), "F")`)
}})
classification(11432) should return "B".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(classification(11432), "B")`)
}})
--seed--
--seed-contents--
def classification(temp):
return temp
--solutions--
def classification(temp):
if temp >= 30000:
return "O"
elif temp >= 10000:
return "B"
elif temp >= 7500:
return "A"
elif temp >= 6000:
return "F"
elif temp >= 5200:
return "G"
elif temp >= 3700:
return "K"
else:
return "M"