Lightning Distance Calculator

lightning-pictureHave you ever seen a lightning flash or heard the thunder of lightning and wondered how close you were from the ligthning strike? Have you noticed that there often was a delay between the flash of light and the clap of thunder when a lightning occurs?

It is possible to calculate the distance to a ligthning strike by counting the seconds between the lightning flash and the sound of thunder.

When lightning strikes, the first thing you see is the flash of light which you can see instantly. This is because light travels at a very high speed (Speed of light = 300,000 km/s). At the same time a clap of thunder is created. However, in the air a sound wave does not travel as fast as light, so it may take a few seconds for this clap of thunder to reach you. This depends on how far you are from the lightning.

Look at the following diagram and check the formula of speed. Bear in mind that the speed of a sound wave in the air is 340 m/s.
lightning-distance
speed-distance-formula

Your Challenge


Write a Python program that asks the end-user to enter a number of seconds. The program should output the distance (in meters or kilometres) from the lightning strike.

Note that 1 mile = 1.609 km, you may want to convert this distance in miles.

Share Button
Posted in Computer Science, Python - Beginner, Python Challenges Tagged with:

Our Latest Book