How do we get g and E values for various levels to calculate electronic partition function
$E_n$ represents the energy of the $n$th electronic state relative to the ground state (i.e. the ground-state electronic energy $E_0 = 0$). Often, electronic states are very high in energy and the excited-state energies $E_1, E_2, \cdots$ are far greater than $k_\mathrm{B}T$, such that $\mathrm{e}^{-E_n/k_\mathrm{B}T} \approx 0$.
Under these conditions, the sum can be collapsed to just a ground-state term
$$q_\mathrm{elec} = \sum_n g_n \mathrm{e}^{-E_n/k_\mathrm{B}T} \approx g_0 \mathrm{e}^{-E_0/k_\mathrm{B}T} = g_0$$
where the latter equality is because $E_0 = 0$. $g_0$ is the degeneracy of the electronic ground state: to find this out you will need to draw some MO diagrams and/or construct the term symbols.
If the ground state is nondegenerate (e.g. $\ce{H2O}$) the whole thing is just equal to 1. Otherwise, for an atom with ground-state term symbol $^{2S+1}L_J$, the degeneracy is $2J + 1$. Similar considerations can be applied to molecules.
However, you will have to watch out for cases where there are low-lying energy states where $E_n$ is on the order of $k_\mathrm{B}T$. I am not aware of an easy way to predict this, though – you will have to know some typical examples, failing which you will just have to look it up, as porphyrin suggests. The NIST WebBook is a good starting place for this.