Sufficient condition for a locally ringed space to be an affine scheme Let $X$ be a locally ringed space.
Let $\mathcal{O}$ be its structure sheaf.
Let $A = \Gamma(X, \mathcal{O})$.
Let $x \in X$.
Let $m_x$ be the maximal ideal of $\mathcal{O}_x$.
Let $f \in A$.
We denote by $f_x$ the image of $f$ by the canonical homomorphism $A \rightarrow \mathcal{O}_x$.
We denote by $f(x)$ the image of $f_x$ by the canonical homomorphism $\mathcal{O}_x \rightarrow \mathcal{O}_x/m_x.$
We write $X_f = \{x \in X|\ f(x) \neq 0\}$.
Is the following proposition true?
Proposition
(1) $X_f$ is open for every $f \in A$.
(2) Let $f_1,\dots,f_n$ be elements of $A$.
Suppose $A = (f_1,\dots,f_n)$ and $X_{f_i}$ is an affine scheme for every $i$.
Then $X$ is an affine scheme.
EDIT
As Zhen Lin and QiL pointed out, (2) is probably false.
However, if $X$ is a Noetherian topological space, (2) is true.
EDIT2
As QiL's edited answer shows, (2) is true after all.
I leave the previous EDIT as it is for the sake of honesty.
EDIT3
This is just a remark.
Suppose $A = (f_1,\dots,f_n)$.
I will show that $X = \bigcup X_{f_i}$.
There exist $a_1,\dots,a_n \in A$ such that $1 = a_1f_1 + \cdots + a_nf_n$.
Let $x \in X$.
Then $1 = a_1(x)f_1(x) + \cdots + a_n(x)f_n(x)$.
Hence $f_i(x) \neq 0$ for some $i$.
Hence $x \in X_{f_i}$ as desired.
 A: (2) is true. if $X$ is a scheme quasi-compact and quasi-separated (e.g. $X$ has a finite covering by affine open subsets $U_i$ and $U_i\cap U_j$ are also covered by finitely many affine open subsets. This is an exercise in Hartshorne. Note first that under the hypothesis of (2), $X$ is a quasi-compact scheme because it is the union of the affine open subsets $X_{f_i}$. Second, as Keenan pointed out in the comment, $X$ is quasi-separated because $X_{f_i}\cap X_{f_j}$ is actually affine being a standard open subset in $X_{f_i}$ defined by $f_j|_{X_{f_i}}\in O(X_{f_i})$. This implies that for all $f\in A$, $\Gamma(X_f, O_X)=A_f$. 
Now consider the canonical map $f : X\to \mathrm{Spec}A=:Y$. For any $i$, $X_{f_i}$ is then isomorphic to $Y_{f_i}$. As the $f_i$'s generate $A$, $X$ (resp. $Y$) is the union of the $X_{f_i}$'s (of the $Y_{f_i}$'s). So $f$ is isomorphism. 
If $X$ is not quasi-separated, there is probably a counterexample. 
A: (1) Note $f(x) \ne 0$ iff $f_x$ is invertible in $\mathcal{O}_x$ which is equivalent to the existence of an open neighborhood $U$ of $x$ such that the restriction of $f$ to $U$ is invertible in $\Gamma(U, \mathcal{O})$.  Hence $X_f$ is precisely the union of those open subsets $U$ such that $f|_U$ is invertible, and hence is open.
