Write Python code to do the following:
1. Create three lists called stars, absmags, and distances containing
stars:
Vega, Deneb, Rigel, Sirius, Arcturus
absmags:
0.582, -8.38, -7.84, 1.42, -0.30
distances:
7.68, 802, 260, 2.64, 11.26
You may be tempted to use numpy
arrays for #2 but don't; use list
comprehensions or mapping instead
(see today's Reading).
2. Now create a new list, appmags, containing apparent magnitudes m calculated
using
$m = M + 5(\log d - 1)$
where M is the absolute magnitude and d is the distance in parsecs. Note that
the logarithm is base-10, so use the $\log_{10}$ function from the math module.
3. Iterate over the stars, printing for each star "The apparent magnitude of (star) is
(appmag)."
4. Practice with dictionaries by creating a dictionary for one of the stars. The keys
should be 'm', 'M', and 'd', and the values should be the apparent magnitude and
so on as appropriate.
5. Now use the data in the four lists to create a nested dictionary called stardict.
Each dictionary entry should have as its key the name of a star, and the value
should be itself a dictionary like the one you created in #4 above.
6. Print stardict['Rigel']['m'].