Determining the quantum expectation value by measuring a single photon