The definition of Expected Value and whether it exist or not. I have some problems understanding the properties of expected value.
Consider a random experiment with 
$S = \mathbb{N}$ 
$\varepsilon  \  =\  2^{S}$, and 
P: $\varepsilon \  \rightarrow [0,1]$.
$X$ is defined $S\rightarrow \  R$
The probability is given:
$ P(\{ k\} )\  =\  \frac{6}{(\pi k)^2} $
Question:How do we find the below equation?
$X(k)\  =\  \begin{cases}-k & \text{if  $k$  is  odd}\\ 
k & \text{if  $k$  is  even}\end{cases}$
I need to prove that the expected value of $X$ does not exist.
I know that I need to calculate the expected value as below:
$\sum^{\infty }_{k=1} kP(X=k)$
Question 2: My study notes say that the above equation is equal to the below one. How do we come up with that mathematically? What is the logic behind it?
$\sum^{\infty }_{k=1} kP(X=k)\  =\  \sum^{\infty }_{k=1} \frac{6}{\pi } \frac{(-1)^{k}}{k}$
If someone can give me a more descriptive explanation that I have, it would be great!
 A: Question 1
I admit I'm not quite sure which equation you're asking about, but both of them are just definitions. They're things that are more or less meant to be taken for granted in this context.
The equation
$$X(k) = \begin{cases} -k, & \text{if $k$ is odd} \\ k, & \text{if $k$ is even} \end{cases}$$
is the definition of the random variable in question. It does not follow from anything else above it, and it cannot be deduced (unless there's more to the problem than you have shared); it's a declaration of how the variable should behave. Morally, this is like saying, "Let $X$ represent the outcome of a fair six-sided die roll."
If you're asking about the equation
$$(\bigstar) \qquad \qquad \mathbb E[X] = \sum k \cdot \mathbb P(X = k)$$
then this typically presented as the definition of the expected value of a discrete random variable. (You can also realize it as a consequence of a measure-theoretic idea instead of a definition, but that's probably not important here.)
The motivation for this definition is that it is a weighted sum of values that $X$ can achieve (i.e. $k$), weighted by the probabilities of assuming those particular values $(\mathbb P(X = k))$.
Question 2
As for why the equation $\sum_{\color{red}{k=1}}^{\infty} k \cdot \mathbb P(X = k) = \sum_{k=1}^{\infty} \frac{6}{\pi} \frac{(-1)^k}{k}$ is justified, this is just plugging the various values that $k$ can be, along with the associated probabilities of it being those values, into the expected value expression.
From the description of $X$, we see that it can assume values like $-1, -3, -5, ...$ with respective probabilities $\frac{6}{\pi^2}, \frac{6}{(3 \pi)^2}, \frac{6}{(5 \pi)^2}, \dots$. It can also assume values like $2, 4, 6, \dots$ with respective probabilities $\frac{6}{(2 \pi)^2}, \frac{6}{(4 \pi)^2}, \frac{6}{(6 \pi)^2}, \dots$. Its expected value should be a sum of all those values, along with the probabilities of being those values:
$$\sum_{k= 1, 3, 5, \dots} -k \cdot \frac{6}{(\pi k)^2} + \sum_{k = 2, 4, 6, \dots} k \cdot \frac{6}{(\pi k)^2}$$
A bit of algebra shows that this expression cleans up to the one you've been given.
You also mentioned in the comments that the expected value does not exist because the series does not absolutely converge. This is correct. Another way you can see the problem is by examining my last expression above, which partitions the series into its positive and negative terms, as a sum of two divergent series.

EDIT: @whoisit has correctly commented that the original post contained some errors that propagated through my answer. I'll try to clean it up here.
The expression $\sum_{k=1}^{\infty} k \cdot \mathbb P(X = k)$ is technically incorrect, since the variable $X$ can assume negative numbers. But, the other sum (to the right of that one) is indeed correct.
Starting with $(\bigstar)$, our summation should be:
$$\sum_{k = -\infty}^{\infty} k \cdot \mathbb P(X = k)$$
since the random variable $X$ maps only onto integers (though not onto all of them). Since the variable $X$ is a one-to-one mapping $\mathbb N \to \mathbb Z$, we could set $j := X^{-1}(k) \iff k = X(j)$ and exchange our sum for
$$\sum_{j = 1}^{\infty} X(j) \cdot \mathbb P(\{j\}) = \sum_{j=1}^{\infty} (-1)^{j}j \cdot \frac{6}{(\pi j)^2}$$
as desired.
