Structure sheaf of $Spec \ k[x,y]$ Let $k$ be a field. We consider the affine scheme $(Spec \ k[x,y], O_{Spec \ k[x,y]})$.
Let $U = D(x) \cup D(y)$. We have that $\Gamma(D(x), O_{Spec \ k[x,y]}) = A_x$ and similarly
$\Gamma(D(y), O_{Spec \ k[x,y]}) = A_y$. I am trying to understand why $\Gamma(U, O_{Spec \ k[x,y]})$ is really just $k[x,y]$. Could someone please explain this? (I understand what sections on a distinguished open base are but I am having trouble understanding what sections are on other open sets) Thank you!  
 A: So what is a global section of $U$? It is just a choice of an element $f \in A_{x}$ and an element $g$ in $A_{y}$ such that $f = g$ in $A_{xy}$. This is because any global section of $U$ can be restricted to $D(x)$ and $D(y)$ in a way that is compatible with further restriction to $D(xy)$.
Now, we can write $f = f'/x^{n}$ where $n \in \mathbb{Z}$ and $f' \in A$ is relatively prime to $x$, and similarly, $g = g'/y^{m}.$ Then,
$$f'y^{m} = g' x^{n}$$
and unique factorization implies that $m = n = 0$ and $f' = g'$. Hence, we can identify the space of global sections of $U$ with $A$.
In more generality, if you cover $U$ with distinguished opens $D(x_{1}), \ldots, D(x_{n})$, then a global section on $U$ is a choice of $f_{i} \in \Gamma(D(x_{i})$ such that 
$$f_{i}|_{D(x_{i}x_{j})} = f_{j}|_{D(x_{i}x_{j})}.$$
Incidentally, your question is an example of the application of the following statement: if $X$ is a normal variety and $f$ is a section defined on an open subset of codimension $\ge 2$, then $f$ extends to a global section of $X$.
