Introduction: Python - Calculate Kardashev Scale Formula/Equation
A short Python program that calculates the Kardeshev Scale using Carl Sagan's formula. Uses the log function from the Math library. Enter the amount of power in terawatts, the program converts it to watts and calculates the Kardashev Scale number. Below and attached.
# Written by Matt R; released under the GPL
import math
print ("Working with log base 10 functions")
# log(number,base)
print ("Calculate the Kardashev Scale using Sagan's formula:")
print (
"""
K = (log P)-6
10
-----------
10
"""
)
print ("Enter the power used by the civilization in Terawatts." )
powerEntered = input("Be sure to enter a number 6.1 or above: ")
# Convert string entered to float number
powerAsFloat=float(powerEntered)
# Error correction
if powerAsFloat <= 6.0:
print ("Please enter a number above 6.0")
else:
# convert terwatts to watts
powerInWatts = powerAsFloat*1000000000000
print ("pwer in watts: ", powerInWatts)
# find base 10 log
logBase10Float = math.log(powerInWatts, 10)
print ("logBase10Float: ", logBase10Float)
# calculate the rating
ratingOfCivilization = (logBase10Float - 6)/10
print ("The Kadashev rating of this civilization is: ", ratingOfCivilization)






