Created
February 11, 2012 07:57
-
-
Save liamlah/1797709 to your computer and use it in GitHub Desktop.
Lorentz mass equation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
speedoflight = 3e8 | |
print "lets work out the mass of something moving at a speed near the speed of light (C)" | |
print "what is the initial mass of your object in kg?" | |
initmass = float(raw_input()) | |
print "what is the velocity of your object in m/s?\n(note: C is 3e8, your input can have up to 17 digits before rounding.)" | |
velocity = float(raw_input()) | |
if velocity == 3e8: | |
print "Watch out, you are trying to divide by zero! Try again." | |
else: | |
finalmass = initmass / math.sqrt( 1.00 - math.pow(velocity, 2) / math.pow(speedoflight, 2)) | |
print "the mass of your object is %rkg" % (finalmass) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment