Let the total mass of the mixture be $100 \,g$
Mass of $H_{2}$ =$\frac{20}{100}\times100=20 \,g$
No. of moles of $H_{2}$ = $\frac{20}{2}=10$ moles
Mass o f $O_{2}$ = $100-20=80 \,g$
No. of moles of $O_{2}$ = $\frac{80}{32} = 2.5 $ moles
Total number of moles of $H_{2}$ and $O_{2}$ = $10+2.5=12.5$
Mole fraction of $H_{2}$ = $\frac{10}{12.5}=0.8$
Total pressure of mixture = 1 bar
$\therefore$ $\quad$ Partial pressure of $H_{2}$ in the mixture, $p_{H_2}$
=Mole fraction \times Total pressure =$0.8\times1=0.8$ bar