What groups have a homomorphic image $\Bbb{Z}/2\Bbb{Z}$? 
Is there a simple characterization for all the groups $G$ so that there exists an epimorphism $\varphi:G\to\Bbb{Z}/2\Bbb{Z}$?

First assume there exists a nontrivial homomorphism $\varphi:G\to\Bbb{Z}/2\Bbb{Z}$. Denote $K=\operatorname{ker}(\varphi)$ and $H=\varphi^{-1}(1)=G\setminus K$. I understand that any such group must have the following properties:

*

*$G/K\cong\Bbb{Z}/2\Bbb{Z}$.

*If $a,b\in H$ and $x\in K$, then $ab\in K$ (since $\varphi(ab)=\varphi(a)+\varphi(b)=1+1=0$) and similarly $ax\in H$.

Is there a more complete characterization of such groups?
Edit: I extend my previuos question and ask the following:

Is there a characterization of all groups $G$ such that there exists a nontrivial homomorphism $\varphi:G\to\Bbb{Z}/n\Bbb{Z}$ for a given $n\in \Bbb{N}$?

 A: This can be phrased as a special case of the group extension problem: you are asking for a classification of extensions of the form
$$1 \to H \to G \to \mathbb{Z}_2 \to 1.$$
The very simplest examples occur when $G \cong H \times \mathbb{Z}_2$; these are just classified by groups $H$. The next simplest occur when the extension splits, meaning $G$ is a semidirect product $H \rtimes \mathbb{Z}_2$; these are classified by pairs of a group $H$ and an action of $\mathbb{Z}_2$ on $H$, more explicitly an involution $\varphi : H \to H$ (an automorphism that squares to the identity), up to conjugation by automorphisms of $H$.
The general case is when the extension does not split. This happens already for $G = \mathbb{Z}_4$. I actually don't know a reference that clearly states the classification in this case, off the top of my head. My preferred way of stating it is that the classification is now given by "homotopy actions" of $\mathbb{Z}_2$ on $H$, but it takes some effort to define and classify these more concretely. A special case that's relatively easy to talk about is that if $H$ is abelian then extensions are classified by a pair consisting of an action of $\mathbb{Z}_2$ on $H$ and a cohomology class in $H^2(\mathbb{Z}_2, H)$; this is enough to recover $\mathbb{Z}_4$, for example.
