Total ages of four female teachers = 4 x 40 = 160
Total ages of eight male teachers = 8 x 25 = 200
Total ages of all the teachers in the school = 160 + 200 = 360
Average ages of all the teachers = total ages of all teacherstotal number of teachers\frac{\text{ total ages of all teachers}}{\text{total number of teachers}}total number of teachers total ages of all teachers
= 36012\frac{360}{12}12360 = 30.