Wearable electronic devices that are designed to be worn on the head of a user while the user is swimming can determine swimming strokes and swimming performances of the user accurately using motion sensors. Using a sound speaker, the wearable electronic device can play music and provide audio feedback to the swimmer. By comparing the swimming performance of the swimmer wearing the device with previously recorded swimming data, the wearable electronic device can provide audio comparison results to the swimmer while the swimmer is swimming in water. To improve water resistance, magnetic switches are utilized as selection switches. The wearable electronic device can also support similar functions for other sports and physical activities.