Solution (source code)

= Solution

Put $A=k[X]$. There is an explicit <isomorphism> from the <principal open subset> $U_f$ to the <affine algebraic set>
$$
Z=V(sf-1)\subset X\times\mathbb A^1,\qquad x\longmapsto(x,f(x)^{-1}).
$$
Its inverse is projection, and both maps are <regular maps>. The <coordinate ring> is
$$
k[Z]=A[s]/(sf-1)\cong A_f,
$$
by the <universal property of localization>. Since <regular functions> on an <affine variety> are its <coordinate ring>, this proves the natural $k$-<algebra isomorphism>
$$
\boxed{k[U_f]\cong k[X]_f.}
$$

Now $W=D(x)\cup D(y)$. A <regular function> on $W$ determines one element of the <function field> $k(x,y)$, and its restrictions belong to $k[x,y]_x$ and $k[x,y]_y$. Conversely, elements of their intersection glue because they agree on $D(xy)$. Thus
$$
k[W]=k[x,y]_x\cap k[x,y]_y\subset k(x,y).
$$
If a reduced fraction has denominator dividing a power of $x$ and also a power of $y$, <unique factorization> makes its denominator a <unit>. Therefore \b[puncturing the plane does not change its ring of global <regular functions>]:
$$
\boxed{k[W]=k[x,y].}
$$
If $W$ were an <affine variety>, its inclusion $j:W\hookrightarrow\mathbb A^2$ would correspond to the identity <isomorphism> $k[x,y]\to k[W]$. The equivalence between <affine varieties> and their <coordinate rings> would make $j$ an <isomorphism>, contradicting the missing origin. Hence \b[$W$ is not affine]. This illustrates <regular functions on the punctured affine plane>: the <coordinate ring> alone does not recover a nonaffine <variety>.