Question: Write a function that converts light - years to miles. Your function should take as input a numerical value representing the number of light -

Write a function that converts light-years to miles. Your function should take as input a numerical
value representing the number of light-years. Your function should then convert this value to miles, and
return the result as its output. It should also print the result of the conversion in the format shown below.
Your function should make sure that the input is nonnegative. If the input is negative, an error message
should be displayed, your output variable should be returned as Not a Number as shown in class, and your
function should return early. Examples of expected input and output:
>ly2mi(1)
1 light-year =5879000000000mi.
ans =
5.8790e+12
>ly2mi(5)
5 light-year =29395000000000mi.
ans =
2.9395e+13
 Write a function that converts light-years to miles. Your function should

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!