Let $k$ denote a field and let $\mathbb{A}^n$ denote affine $n$-space. Then if I understand correctly, it's best to view $\mathbb{A}^n$ as a ringed space. I'm a bit unsure as to what the structure sheaf is though, and this seems not to be easily found on the internet. If I had to guess, I'd say that for $U \subseteq \mathbb{A}^n$ open in the Zariski topology, the definition of $\mathcal{O}(U)$ is probably $$\left\{\frac{f}{g} : f,g \in k[n], g \neq 0, V(g) \cap U = \emptyset\right\}.$$
(I write $k[n]$ for the set of polynomials in $n$-variables.)
Is this right? I'd also appreciate a reference that describes classical objects like (the set of closed points of) affine space from the ringed space perspective. This seems to be hard to find, as most texts dive into schemes rather quickly.
If $\mathbb{A}^n$ refers to $\operatorname{MaxSpec} k[n]$ as you seem to have in mind based on the comments, then the structure sheaf on $\mathbb{A}^n$ is just the restriction of the structure sheaf on $\operatorname{Spec} k[n]$. In fact, this is really basically the same sheaf: an open subset of $\operatorname{Spec} k[n]$ is determined by the closed points it contains (this is part of what the Nullstellensatz says), so the inclusion map $\operatorname{MaxSpec} k[n]\to \operatorname{Spec} k[n]$ induces an isomorphism on lattices of open sets. So a sheaf on $\operatorname{MaxSpec} k[n]$ is really exactly the same thing as a sheaf on $\operatorname{Spec} k[n]$; you've just removed all the generic points from your open sets.
Concretely, your description is basically correct. If $U\subseteq\mathbb{A}^n$ is a nonempty open set, then $\mathcal{O}(U)$ is the subring of $k(n)$ consisting of rational functions which can be written with a denominator which vanishes nowhere on $U$. (If $U=\emptyset$, then of course $\mathcal{O}(U)$ is the zero ring.) Note that it is important here that "vanishes nowhere on $U$" includes points of $U$ with residue field besides $k$, so we really aren't thinking of polynomials as just functions on $k^n$ as you seem to be implying.