You take the number of girls over total students which is boys + girls. Since there's 40 boys and 60 girls, it's 60 girls to 100 students which can be written in several ways.
You first add the total number of students which is (40boys + 60girls) which gives us 100 students.
Then arrange the ratio of girls to students as per the question that is 60:100, reduce it to its lowest term that is dividing the ratio by 20, and finally got 3:5