20 mL of 0.1 M solution of weak acid was mixed with 8 mL 0.1 M solution of NaOH. Measured pH was 5.12. Calculate pKa.
In the case of not-so-weak acids you can assume the neutralization reaction is quantitative (all of the strong base reacts with the weak acid) and the pH of the solution is described by Henderson-Hasselbalch equation:
All you have to do is to find out concentrations of A- and HA. However, it is worth of noting here, that you can save part of the calculations, replacing concentrations with numbers of moles - volume is the same for both substances so it cancels out.
Solution was prepared using 20×0.1=2 mmol of acid and 8×0.1=0.8 mmol of strong base. If the reaction was quantitative after the neutralization there was 1.2 mmol of acid HA left and 0.8 mmol of A-. Inserting these values into Henderson-Hasselbalch equation gives 5.12=pKa+log(0.8/1.2). Solving for pKa you get pKa=5.12-log(0.8/1.2)=5.12+0.18=5.30.
pH calculator can help you check this result. Enter 5.3 as pKa, 0.1 as concentration of acid, select sodium hydroxide as a base, enter 0.1 as its concentration, finally select Ca+Cb+Va+Vb as a way of expressing solution composition and enter 20 and 8 as acid and base solutions volumes - and the pH displayed will be 5.12, confirming the result.
Note that for strong or very weak acids and/or for very diluted solutions this method may give wrong results - when pH is further changed by dissociation or hydrolyzis or when the water autodissociation can't be neglected.