The kinetic energy of H and O nuclei has been studied by path integral molecular dynamics simulations of ice Ih and water at ambient pressure. The simulations were performed by using the q-TIP4P/F model, a point charge empirical potential that includes molecular flexibility and anharmonicity in the OH stretch of the water molecule. Ice Ih was studied in a temperature range between 210-290 K, and water between 230-320 K. Simulations of an isolated water molecule were performed in the range 210-320 K to estimate the contribution of the intramolecular vibrational modes to the kinetic energy. Our results for the proton kinetic energy, KH , in water and ice Ih show both agreement and discrepancies with different published data based on deep inelastic neutron scattering experiments. Agreement is found for water at the experimental melting point and in the range 290-300 K. Discrepancies arise because data derived from the scattering experiments predict in water two maxima of KH around 270 K and 277 K, and that KH is lower in ice than in water at 269 K. As a check of the validity of the employed water potential, we show that our simulations are consistent with other experimental thermodynamic properties related to KH , as the temperature dependence of the liquid density, the heat capacity of water and ice at constant pressure, and the isotopic shift in the melting temperature of ice upon isotopic substitution of either H or O atoms. Moreover, the temperature dependence of KH predicted by the q-TIP4P/F model for ice Ih is found to be in good agreement to results of path integral simulations using ab initio density functional theory.