Question

In: Computer Science

A light year is the distance light travels in 1 year. Light travels at 3*108 meters*...

A light year is the distance light travels in 1 year.

Light travels at 3*108 meters* sec-1.

Write a program that calculates and displays the number of meters light travels in a year.

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

Let me know for any help with any other questions.

Thank You!
===========================================================================

c = 3 * 10 ** 8 # speed of light

seconds_in_year = 365 * 24 * 60 * 60 # total seconds in a year

distance = c * seconds_in_year    # distance = speed* time 

print('Light travels {:,} meters in a year.'.format(distance))

================================================================


Related Solutions

comments please Your program will calculate the distance an object travels (in meters) on Earth for...
comments please Your program will calculate the distance an object travels (in meters) on Earth for a specified number of seconds. You will also calculate the distance traveled on the Moon (in meters) for the specified number of seconds. Your program must have the main function and, at least, the following four additional functions. The signatures for these functions must be as follows: double readSeconds() double calculateEarthDistance(double seconds) double calculateMoonDistance(double seconds) void displayResults(double seconds, double earthDistance, double moonDistance) The readSeconds...
The speed of light 3 × 108 m / s, can be expressed in terms of...
The speed of light 3 × 108 m / s, can be expressed in terms of other fundamental constants relating to electricity and magnetism. Give this algebraic expression and briefly explain where it comes from.
During a test a rocket travels upward at 75 meters/second, and when it is 40 meters...
During a test a rocket travels upward at 75 meters/second, and when it is 40 meters from the ground its engine fails. Determine the maximum height h reached by the rocket and its speed just before it hits the ground. While in motion the rocket is subjected to a constant downward acceleration of 9.81 m/s2 due to gravity. Neglect the effect of air resistance.
The distance a vehicle travels can be calculated as follows: Distance = Speed * Time For...
The distance a vehicle travels can be calculated as follows: Distance = Speed * Time For example, if a train travels 40 miles-per-hour for three hours, the distance traveled is 120 miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. Both values are assumed to be integers. It should use a loop to display the distance a vehicle has traveled for each hour of a time period...
Using Python Write a GUI program that converts a distance in Meters to the equivalent distance...
Using Python Write a GUI program that converts a distance in Meters to the equivalent distance in Feet. The user should be able to enter a distance in Meters, click a button, and then see the equivalent distance in feet. Use the following formula to make the conversion: Meters = Feet x 0.304 For example, 1 Meter is 3.28 Feet.
A car travels a certain distance along a straight road (in the +x direction). The distance...
A car travels a certain distance along a straight road (in the +x direction). The distance the car travels as a function of time is shown in the figure below. When the car changes speed it does so uniformly. Select the appropriate choice for each statement. It wont let me post the photo of the graph for some reason, so here is a link to it https://d2vlcm61l7u1fs.cloudfront.net/media%2Fa8f%2Fa8f89426-1896-44e8-863a-df989e927825%2FphpeLSO6i.png The acceleration magnitude at 15 sec is ..... the acceleration magnitude at 37...
A rectangular room is 12 meters long, 6 meters wide, and 3 meters high. 1] Calculate...
A rectangular room is 12 meters long, 6 meters wide, and 3 meters high. 1] Calculate the first three axial modes for the length of the room.   2] Find the wavelength, then convert to frequencies, assuming that the speed of sound in the room is 343 m/s. 3] Calculate the first 3 axial modes [Wavelenghts and frequencies] for the width of the room. 4] Calculate the first axial modes [Wavelenghts and frequencies] for the height of the room. It is...
Originally, light is unpolarized. It then travels through 3 polarizers: the first with its transmission axis...
Originally, light is unpolarized. It then travels through 3 polarizers: the first with its transmission axis aligned vertical, the next at a 30 degree angle to the vertical and the last aligned at a 45 degree angle to the vertical (tilted the same direction as the first with respect to the vertical). The original intensity of light is 4 W/m2. 1-What is the intensity of light after the second polarizer? 2-What is the intensity of light after the third polarizer?...
1. Suppose it is claimed that the typical adult travels an average distance of 16 miles...
1. Suppose it is claimed that the typical adult travels an average distance of 16 miles to get to work each day. You believe this average is too low for Columbus residents. You survey a random sample of 98adults from Columbus and find that your sample travels an average distance of 17.6 miles to work each day, with a sample standard deviation of 7.8 miles.   Use this information to conduct the appropriate hypothesis test by going through the steps you...
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance...
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance = speed * time For example, if a train travels 40 miles per hour for 3 hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle has traveled for each...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT