Disclaimer : I know zilch about combinatirics. This problem might have elegant (and already programmed) solutions among the combinatorics tools of Sage. However, the problem seems simple enough to attempt a "naïve" solution.
A function from X to Y is the set of tuples [(xi,yj),...,i=1,…,n,j∈[0..n]], meaning that xi has yj as image, the notation (xi,y0) denoting the case where xi has no image. Let Sn,m the set of all functions from X to Y when X has n elements and Y has m elements.
1): the set S1,m is simply [(x1,yj),j=0,...,m].
2): knowing Sn,m, one can simply build Sn+1,m by adding (i. e. concatenating) to each of the functions in Sn,m a member of [(xn+1,yj),j=0,...,m]. In other words, S_{n+1,m}$ is the cartesian product of Sn,m and [(xn+1,yj),j=0,...,m].
3): 1) and 2) are sufficient to build Sn,m by recurrence on n. It results immediately that the cardinal is (m+1)n, including the degenerate case where no element of X has an image in Y.
The implementation, whose details depend of the planned use of the functions, is, as usual, left to the reader as an exercise ;-).