Light travels at 3 × 108 meters per second. A light-year is the distance a light beam travels in one year.Write a PYTHON program that calculates and displays the value of a light-year.Useful facts:Seconds in a year = 365×24×602Rate = 3×108meters per second

Respuesta :

Answer: This is a python code

def lightyear():

   rate=3*100000000   //speed of light

   seconds=365*24*60*60   //number of seconds in 1 year

   return str((rate*seconds)/1000)+" km"    //distance=speed x time

print(lightyear()) //will print value of light hear in kilometers

OUTPUT :

9460800000000.0 km

Explanation:

In the above code, there is a variable rate, which stores the speed of light, i.e. distance traveled by light in 1 second which is in meters. Another variable is seconds, which store the number of seconds in 1 year, which is no of days in 1 year multiplied by the number of hours in a day multiplied by the number of minutes in an hour multiplied by the number of seconds in a minute. Finally, distance is speed multiplied by time, so distance is printed in kilometers and to convert distance in kilometers it is divided by 1000.