Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How much do things weigh on the moon? Let's write a program in python to do the calculation for us . On the moon, we

How much do things weigh on the moon? Let's write a program in python to do the calculation for us. On the moon, we can calculate our weight using the acceleration due to gravity. On earth the acceleration due to gravity is 9.81ms2, while on the moon this drops to 1.62ms2. We can use this acceleration to figure out the change in weight by using the formula:
MoonWeight =EarthWeight9.81ms2**1.62ms2
Note: the units of the weight do not matter, whatever unit you put in is what you will get out.
Write a function called moon_weight that takes no parameters, but interacts with the user to produce the following output for any given weight and returns only the value as a string.
Ask the user for a string using the console (terminal)
Required prompt: 'Please enter a weight on Earth and I will tell you what it will be on the moon:'
Perform the required transformations on the user input to obtain a numeric value as in the equation
return a string that is formatted to exactly 2 decimal places in all conditions note that some python functions will truncate values when they end in a 0. Be sure to test your function adequately.
printing to the console is not the same thing as returning a value (even though it looks that way in the output examples)
Show exactly 2 decimal places in your response:
16.51 NOT 16.5122165466456
16.50 NOT 16.5
Examples of the function running should appear as follows:
1 moon_weight ()
2 Please enter a weight on Earth and I will tell you what it will be on the moon: 100
316.51
4 Moon_weight ()
5 Please enter a weight on Earth and I will tell you what 1t will be on the moon: 99.92
6,16.50
What is the purpose, parameter and return for this question?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Why is a fine grain size often desired in an engineering metal?

Answered: 1 week ago

Question

Carry out an interview and review its success.

Answered: 1 week ago