Let us write again the balanced equation:
H_2(g)+Br_2(g)->2HBr(g)
In order to find the amount of HBr(g) that will form we will need to know which one is the limiting reactant.
color(green)("Using 5mol "H_2):
?molHBr=5cancel(molH_2)xx(2molHBr)/(1cancel(molH_2))=color(green)(10molHBr)
color(red)("Using 7mol "Br_2:
?molHBr=7cancel(molBr_2)xx(2molHBr)/(1cancel(molBr_2))=color(red)(14molHBr)
In general, the reactant that produces the least amount of HBr is the limiting reactant. Therefore, H_2 is the color(green)("limiting reactant") and Br_2 is the color(red)("excess reactant").
Since color(green)(1molH_2) reacts with color(red)(1molBr_2), therefore, color(green)(5molH_2) will react only with color(red)(5molBr_2) and the excess amount of Br_2 is color(red)(2molBr_2).
In order to find the mass in grams for the excess Br_2 remaining after reaction:
n=m/(MM)=>m=nxxMM
m=2cancel(molBr_2)xx(80gBr_2)/(1cancel(molBr_2))=160gBr_2