Exercise 2 - Solutions
# Satellites:
sat_database = {"METEOSAT" : 3000,
"LANDSAT" : 30,
"MODIS" : 500
}
# The dictionary above contains the names and spatial resolutions of some satellite systems.
# 1) Add the "GOES" and "worldview" satellites with their 2000/0.31m resolution to the dictionary [2P]
sat_database["GOES"] = 2000
sat_database["worldview"] = 0.31
print(sat_database)
print("I have the following satellites in my database:")
# 2) print out all satellite names contained in the dictionary [2P]
for key in sat_database.keys():
print(key)
# 3) Ask the user to enter the satellite name from which she/he would like to know the resolution [2P]
user_input = input("\nFrom which satellite would you like to know the resolution? ")
# 4) Check, if the satellite is in the database and inform the user, if it is not [2P]
if user_input in sat_database.keys():
print("The resolution of {0} is: {1:1.2f}m".format(user_input,sat_database[user_input]))
# 5) If the satellite name is in the database, print a meaningful message
# containing the satellite name and it's resolution [2P]
else:
print("I do not have the satellite '{}' in my database.".format(user_input))