Python - Calculating the Redshift Value
by matt392 in Circuits > Software
46 Views, 1 Favorites, 0 Comments
Python - Calculating the Redshift Value

Python program that calculates a redshift value. Attached and below.
print ("Calculate the redshift of a star or galaxy using the change in wavelength.") answer = "y" # Start while loop while (answer == "y"): # Observed wavelength entered by user and converted to an integer observedWavelength = int(input("Enter the observed wavelength in Angstroms: ")) # Wavelength of element entered by user and converted to an integer elementWavelength = int(input("Enter the element's wavelength in Angstroms: ")) # Calculate the change or shift in the wavelength changeWavelength = observedWavelength - elementWavelength print ("The formula is: redshift = (change in wavelength/wavelength of the element)") redshift = (changeWavelength/elementWavelength) print ("The redhshift of the star or galaxy is:", redshift) print ("Note that a positive value means the object is moving away from Earth.") print ("A negative value means that the object is moving towards Earth.") answer = input("Would you like to do another calculation? (y/n) ") # End while loop print ("Thank you to Professor Morgan at the University of Northern Iowa for the formula and explanation.")