Can you please answer this question: Both water and carbon dioxide are triatomic molecules. Explain why one of these molecules is polar and the other is nonpolar?

Carbon dioxide is linear :C::O::C: and therefore has no net electrical dipole.

Water is a bent molecule , so the O side acts a negative, making the molecule polar.
http://library.tedankara.k12.tr/chemistry/vol2/hydrogen%20bonding/z20.jpg

CO2 is a linear molecule like this
O=C=O. The difference in electronegativity (EN) of the O and C makes the left O=C bond polar and the right C=O bond polar but the linear symmetry cancels each other and the molecule as a whole is not polar. That isn't so with the water molecule. It is not linear. It's tough to draw the structure on these boards but it looks something like this.
H
|
O - H.
Now the difference of one EN for O and H makes both bonds polar (as in the case of CO2) but the water molecule is not linear, hence it isn't symmetrical, and the two polar bonds don't cancel each other. That is to say that there is a net dipole moment.

why is water a bent molecule, but carbon dioxide is linear?

Water is bent because of the two lone pairs of electrons on the oxygen atom. These lone pairs of electrons cause the molecule to be bent, rather than linear. Carbon dioxide is linear because the two oxygen atoms are bonded to the carbon atom in a linear fashion, and the lone pairs of electrons on the oxygen atoms do not cause the molecule to be bent.

The shape of a molecule depends on its electron arrangement and the repulsion between these electrons. In the case of water, it has two lone pairs of electrons on the oxygen atom and two hydrogen atoms attached to it. The repulsion between these electron pairs causes the molecule to adopt a bent or V-shaped structure, with the oxygen atom at the center and the hydrogen atoms at the tips of the "V".

On the other hand, carbon dioxide has two oxygen atoms attached to a central carbon atom. The arrangement of the three atoms is linear, with the carbon atom in the center and the oxygen atoms on either side in a straight line. This linear shape is due to the repulsion between the electron pairs in the molecule.

The difference in shape between water and carbon dioxide is a result of the number and arrangement of electron pairs around the central atom. In water, the presence of two lone pairs of electrons on the oxygen atom causes a greater electron-electron repulsion, resulting in a bent shape. In carbon dioxide, there are no lone pairs of electrons on the central carbon atom, leading to less electron-electron repulsion and a linear shape.

The shape of a molecule depends on the arrangement of atoms and the presence of lone pairs of electrons. In the case of water (H2O), there are two bonded pairs of electrons and two lone pairs on the central oxygen atom. The arrangement of these electron pairs forms a bent or V-shaped structure, resulting in a molecule with a bent shape.

On the other hand, carbon dioxide (CO2) has one carbon atom bonded to two oxygen atoms by double bonds. The arrangement of these atoms and the absence of lone pairs results in a linear structure. The carbon atom is located in the center, with the oxygen atoms on opposite sides of it.

The difference in the arrangement of atoms and lone pairs in water and carbon dioxide is due to the differences in the number of bonded and lone pairs of electrons present on the central atom. This leads to different molecular geometries and shapes for these molecules.