As other people said, distance to the sun is irrelevant, but there are a bunch of different factors that determine the temperature. If you Google graphs of average temperature vs height you will see it’s not always colder the higher you go, so it’s colder the higher you go up to a point, then it gets hotter, then colder…
Latest Answers