Simple math.
Probability is equal to number of ways it can happen over total number of outcomes.
or simply
P = n1 + n2 + n3 ... / nTotal
So in your question
We just need to add all of it to know the total outcomes.
We have,
6 + 4 + 4 + 2 + 8 = 24
There are 24 of total outcomes now.
And add the number of purple and black pencil.
purple has 2 and black has 8
In total we have 10
10 will represent the number of ways it can happen.
Time to solve.
P = 10 / 24
therefore,
P = 5/12
So the probability of Annie having purple and black pencil is 5/12 or 0.42
I hope it helps.