27 students is basically the sum of their ratios 4:5
We can define the proportion with an arbitary variable x ->
4x:5x
Which is the ratio of packed to bought lunch. Therefore, 4x + 5x = 9x. 9x =27
x=3
The students that bought their lunch were the 5x group, therefore 15 students bought lunch.