Question: Your task is to write a program which asks the user to input the name of a planet with the attribute name, and the program

Your task is to write a program which asks the user to input the name of a planet with the attribute name, and the program will show the value for this attribute

The density and gravity of each planet are:

Planet Density (kg/m^3) Gravity (m/s^2)
mercury 5429 3.7
venus 5243 8.9
earth 5514 9.8
mars 3934 3.7
jupiter 1326 23.1
saturn 687 9.0
uranus 1270 8.7
neptune 1638 11.0

In your code you shall define a dictionary constant containing the data in the above table, using the appropriate data types for keys and values. The dictionary must consist of planet data. The attribute in each planet must be represented in disctionary as well. Next, ask the user to input a planet name. If the planet name is in the dictionary, the program will ask the attribute name. If the attribute is in the planet's dictionary, the value of this attribute will be displayed. If the planet is recognised but the attribute is not recognised, display the message "Unrecognised Attribute". Otherwise, display the message "Unrecognised planet".

To be more user-friendly, you must also ignore the capitalisation of the input name when checking it (i.e. "mercury", "MERCURY", and "Mercury" are all accepted by the program).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!