For each of the following Richter scale measurements, your python program should perform the
appropriate calculations and display the equivalent amount of energy in joules and in tons TNT Explosion:
• 1.0
• 5.0
• 9.0 (Kamchatka, 1952)
• 9.1 (Indonesia earthquake, 2004)
• 9.5 (Chile earthquake, 1960)
• 5.0
• 9.0 (Kamchatka, 1952)
• 9.1 (Indonesia earthquake, 2004)
• 9.5 (Chile earthquake, 1960)
Your program should prompt the user to enter a Richter scale Value, accept a floating point number representing that measurement, perform the appropriate calculations, and display the equivalent amount of energy in joules and in tons of exploded TNT for that user-selected value.
You can visit Earthquake Power Calculator, to get some insight about the problem. To raise a number to a power, use the ** operator. Your output should look like this.
Click the Python code to see a Solution
Python Code
import math
def Richter_Joules( scale ):
sum=(1.5*scale)+4.8
return 10**sum
def Richter_TNT( R_scale ):
val=Richter_Joules(R_scale)/(4.184*10**9) # One ton TNT yields 4.184x109 #joules
return val
L=[1.0, 5.0, 9.0, 9.1, 9.5]
def main( ):
print( "Richter Joules TNT" )
print("{ } { } { }".format( L[0], Richter_Joules( L[0] ), Richter_TNT( L[0] ) ))
print("{ } { } { }".format( L[1], Richter_Joules( L[1] ), Richter_TNT( L[1] ) ))
print("{ } { } { }".format( L[2], Richter_Joules( L[2] ), Richter_TNT( L[2] ) ))
print("{ } { } { }".format( L[3], Richter_Joules( L[3] ), Richter_TNT( L[3] ) ))
print("{ } { } { }".format( L[4], Richter_Joules( L[4] ), Richter_TNT( L[4] ) ))
print("\n")
r=float( input( "Please enter a Richter Scale Value : " ) )
print( "Richter Scale Value: ", r)
RJ = Richter_Joules(r)
RT = Richter_TNT(r)
print( "Equivalence in joule:", RJ)
print( "Equivalence in tons of TNT: ", RT)
main()
def Richter_Joules( scale ):
sum=(1.5*scale)+4.8
return 10**sum
def Richter_TNT( R_scale ):
val=Richter_Joules(R_scale)/(4.184*10**9) # One ton TNT yields 4.184x109 #joules
return val
L=[1.0, 5.0, 9.0, 9.1, 9.5]
def main( ):
print( "Richter Joules TNT" )
print("{ } { } { }".format( L[0], Richter_Joules( L[0] ), Richter_TNT( L[0] ) ))
print("{ } { } { }".format( L[1], Richter_Joules( L[1] ), Richter_TNT( L[1] ) ))
print("{ } { } { }".format( L[2], Richter_Joules( L[2] ), Richter_TNT( L[2] ) ))
print("{ } { } { }".format( L[3], Richter_Joules( L[3] ), Richter_TNT( L[3] ) ))
print("{ } { } { }".format( L[4], Richter_Joules( L[4] ), Richter_TNT( L[4] ) ))
print("\n")
r=float( input( "Please enter a Richter Scale Value : " ) )
print( "Richter Scale Value: ", r)
RJ = Richter_Joules(r)
RT = Richter_TNT(r)
print( "Equivalence in joule:", RJ)
print( "Equivalence in tons of TNT: ", RT)
main()