Atomic mass ratios - Is the problem providing enough info?
Are you asking whether we can figure out the ratio of the mass of an oxygen atom to a hydrogen atom from this information? If so, then the answer is yes, assuming that you know that $\ce{H2O}$ and $\ce{H2O2}$ are the formulas for each compound, and that atoms exist and are indivisible in chemical reactions.

$$2n\space \rm{atoms \space H} = 1 \space g \space H$$
$$1n \space \rm{atoms \space O} = 8 \space g \space O$$

Divide the second equation by the first:

$$\frac{1n \space \rm{atoms \space O}}{2n\space \rm{atoms \space H}} = \frac{8 \space g \space O}{1 \space g \space H}$$

Cross multiply to get a 16:1 mass ratio. You can confirm this by looking at $\ce{H2O2}$, where the ratio of atoms is 1:1 and mass is again 16:1.

If you didn't know the formulae, then you could assume that the ratio was some integer multiple of 8:1, but without more data you wouldn't know which. This is because you would not know whether water had a 1:1 atom (or mole) ratio of $\ce{H}$ to $\ce{O}$, or if it was something else.

Incidentally, what you are describing is the law of multiple proportions, and it is one of the key findings that led to the development of atomic theory.