Your thinking for a) is correct ... but your formula is not quite right. If you define $P(A)$ as the probability of a student attending and passing , and $P(B)$ the probability of a student not attending and passing, then the probability of passing is simply $P(A)+P(B)$.
That is, you don't further multiply $P(A)$ by $0.79$, but rather, you figure out $P(A)$ by multiplying the $0.97$ by $0.79$. That is:
$P(A)=0.97\cdot 0.79$
Likewise:
$P(B)=0.19\cdot 0.21$
For b): Note that $P(A)+P(B)$ gives you the percentage of students that passed the exam. So, what part of that is made up by students who attended regularly? That will be the probability of Sam attending regularly, given that Sam was one of those who passed. For example, if $P(A)$ turns out to be $.4$, i.e. $40$%, and $P(B)$ turns out to be $0.2$, i.e. $20$%, then out of all those students who passed the exam (which is $20+40=60$% of all stduents), the proportion that attended regularly is $\frac{0.4}{0.6}$