Landing site
NASA's Perseverance rover landed in Jezero crater on Mars in February 2021. Mission planners store every site as a pair of numbers, latitude and longitude, that always belong together and in that order.
Keep the pair in a tuple, unpack it, then print it the way maps and mission documents write coordinates.
Finish stage 1 to unlock this stage.
Unpack the tuple into two variables, lat and lon, in one line, then print both with four decimal places:
Latitude: 18.4447 Longitude: 77.4508
a, b = pair puts the first value in a and the second in b. :.4f shows four decimal places.
Finish stage 1 to unlock this stage.
Maps don't write negative coordinates: they write the number without its sign and a letter, N or S for latitude and E or W for longitude. Add a line in that form:
Latitude: 18.4447 Longitude: 77.4508 Site: 18.4447° N, 77.4508° E
Choose each letter with an if: 0 and above is N or E, below 0 is S or W. abs() gives a number without its sign. Curiosity's landing site, (-4.5895, 137.4417), would be 4.5895° S, 137.4417° E.
Hints
Tuple Unpacking
# Tuple unpacking: one line, many variables
# New Horizons flyby of Pluto, 14 July 2015
flyby = ("New Horizons", "Pluto", 12472)
probe, target, closest_km = flyby
print(f"{probe} passed {target} at {closest_km} km")
# Asterisk grabs everything that is left over
ares3 = ("Lewis", "Johanssen", "Martinez", "Vogel", "Beck", "Watney")
commander, *crew, botanist = ares3
print("Commander:", commander)
print("Crew:", crew)
print("Left behind on Mars:", botanist)
# Swapping two values without a temporary variable
primary_dish, backup_dish = "Goldstone", "Canberra"
primary_dish, backup_dish = backup_dish, primary_dish
print(f"Now transmitting from {primary_dish}, backup is {backup_dish}")
# Underscore marks a value you do not need
sample = ("Ryugu", 2020, 5.4)
asteroid, _, grams = sample
print(f"Hayabusa2 returned {grams} grams of {asteroid}")
# Unpacking inside a for loop
moons = [("Titan", 5150), ("Enceladus", 504), ("Iapetus", 1469)]
for name, diameter_km in moons:
print(f"{name}: {diameter_km} km across")
Separate arguments with commas. They're passed on every Run as sys.argv[1:].