Python - Stefan-Boltzmann Law

by matt392 in Circuits > Software

54 Views, 1 Favorites, 0 Comments

Python - Stefan-Boltzmann Law

stefanboltzmannlawgraphic.png
print ("This program will calculate the Stefan-Boltzmann Law.")

#  Stefan-Boltzmann Forumula is:
#  Energy = [Stefan-Boltzmann constant (represented by letter sigma)] * [T**4]
#  Stefan-Boltzmann constant:  5.67 * (10**−8)
#  T = temperature of the object
###########################################

#  Function to solve for energy
#    Solve for e: enter t (temperature of object) 
#    Stefan-Boltzmann constant is: 5.67 * (10**−8)
#    Formula: e = [sigma * (t**4)]
def solveForEnergy():
    print ("Solving for Energy")
    temperature = int(input("Please enter the temperature: ") )
    stefanBoltzmannConstant = (5.67 * (10**-8) )
    energy = (stefanBoltzmannConstant) * (temperature**4)
    
    print("The energy is:", energy, "watts/square meter")
    
continueCalculations = "y"

# Check to see if the user wants to continue to calculate Stefan-Boltzmann Law
while (continueCalculations=="y"):
    solveForEnergy()
    continueCalculations = input("Would like to do another calculation for the Stefan-Boltzmann? (y/n): ")
    
print("==================================")
print ("Thank you to Professor Morgan at the University of Northern Iowa for the formula and explanation.")

Downloads