Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this task, you are to write code that tells the user about a planet feature. Instructions Your task is to write a program which
For this task, you are to write code that tells the user about a planet feature. Instructions 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: Source: https:/ssdc.gsfc.nasa.gov/planetary/factsheet/ 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). Hint: Ensure that planet names in your dictionary are all in lowercase, then use the appropriate string method to convert the user input to lowercase also. Criteria During marking we will check that your program: - Defines a dictionary constant containing planet names with density and gravity attributes and use this in your code. Give the constant an appropriate name which follows Python conventions. (6 marks) - Defines a dictionary constant containing measurement units and use this in your code. Give the constant an appropriate name which follows Python conventions. ( 3 marks) - Accents the nlanet name from the user with an annronriate innut statement (2 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started