Use the formulas:
E=hnu, where E is energy (J), h is Planck's constant (Js), and nu is the frequency (Hz).
and
c=lambdanu, where c is the speed of light in a vacuum (m/s), lambda is the length of a wavelength (m), and nu is the frequency (Hz).
Solving the second formula for nu, we get nu=c/lambda
Combining these formulas, we get:
E=(hc)/lambda
For the first question, we are given that lambda=40 nm or 40*10^-9 m. By substituting into the above formula, we get:
E=((6.626*10^-34)(3*10^8))/(40*10^-9)=4.9695*10^-18
E=5.0*10^-18 "J" with proper significant figures
For the second question, we can use our answer for the first question (the amount of energy for a single photon) and Avogadro's number to find the the amount of energy in a mole of photons with wavelength of 40*10^-9 m:
E=(4.9695*10^-18)*(6.02*10^23)=2.99164*10^6
E=3.0*10^6 "J/mol" with proper significant figures