What is a mapping? Why are there $k^n$ mappings from $[n]$ to $[k]$? Apologies for a rather basic question. My previous understanding was that mapping is a function from a set to another set. 
Now a combinatorics textbook states that the total number of mappings from $\{1,2,\dots,k\}$ to $\{1,2,\dots,n\}$ is $n^k$.
Why so? If possible, could you please also explain what those mapping are in this case?
Thank you.
 A: Let $B^A = \{ \text{functions } f : A \to B \}$. Suppose $0^0 = 1$ (consider the case $\emptyset^\emptyset$) and let $A,B$ be finite sets.
Here is a (rather) formal proof of $|B^A| = |B|^{|A|}$ by Induction over $k = |A|$:
If $k=0$, then $A = \emptyset$, so $|B|^{|A|} = |B|^0 = 1 = |B^\emptyset| = |B^{A}|$. (for every set $B$ there is a unique map $\emptyset \to B$, which has an empty graph)
Suppose the proposition holds for $k-1\in \mathbb{N}_0$. Then $|A|\geq 1$. Let $a\in A$ and $A' = A\setminus \{a\}$. Then $A = A' + \{a\}$. So:
$$|B^A| = |B^{A' + \{a\}}| = |B^{A'}\times B^{\{a\}}| = |B^{A'}|\cdot |B^{\{a\}}| =^{IH} |B|^{|A'|} \cdot |B|^1 = |B|^{|A'| + 1} = |B|^{|A|}$$
Here $+$ denotes a disjoint union and $\times$ cartesian product. I used some other combinatorial properties, including:


*

*$|A\times B| = |A|\cdot|B|$

*$|C^{A+B}| = |C^A \times C^B|$ (I only need this for $|B|=1$)


If you dislike the case $k=0$ for some reason, you may also start with $k=1$ and treat this case seperately.
