# Python code to apply the theorem of conservation of mechanical energy # Constants g = 9.81 # gravitational acceleration in m/s^2 # Function to calculate the total mechanical energy def calculate_mechanical_energy(mass, height, velocity): # Potential energy potential_energy = mass * g * height # Kinetic energy kinetic_energy = 0.5 * mass * velocity ** 2 # Total mechanical energy total_energy = potential_energy + kinetic_energy return potential_energy, kinetic_energy, total_energy # Example usage # Inputs mass = 2.0 # mass in kg initial_height = 10.0 # height in meters initial_velocity = 0.0 # velocity in m/s # Calculate energy at the initial position potential_energy, kinetic_energy, total_energy = calculate_mechanical_energy(mass, initial_height, initial_velocity) print("Initial state:") print("Potential energy:", potential_energy, "J") print("Kinetic energy:", kinetic_energy, "J") print("Total mechanical energy:", total_energy, "J") # Final state inputs final_height = 0.0 # height in meters final_velocity = (2 * g * initial_height) ** 0.5 # velocity at final state using energy conservation # Calculate energy at the final position potential_energy, kinetic_energy, total_energy = calculate_mechanical_energy(mass, final_height, final_velocity) print("\nFinal state:") print("Potential energy:", potential_energy, "J") print("Kinetic energy:", kinetic_energy, "J") print("Total mechanical energy:", total_energy, "J")