If $X,Y$ are locally ringed spaces over a locally ringed space $S$, then one can write down their fiber product $X \times_S Y$ explicitly. If $X,Y,S$ are schemes, then this fiber product is a scheme, so that it is the fiber product in the category of schemes. This provides an alternative (and in my opinion far better) construction of the fiber product of schemes which is not well-known as it should be. You can find it here. Let me sketch it:
Let $f : X \to S$ and $g : Y \to S$. The underlying set of $X \times_S Y$ consists of those triples $(x,y,s,\mathfrak{p})$, where $(x,y,s)$ lies in the underlying topological fiber product, i.e. $x \in X, y \in Y, s \in S$ and $f(x)=s=g(y)$, and $\mathfrak{p}$ is a prime ideal in $\kappa(x) \otimes_{\kappa(s)} \kappa(y)$, the tensor product of the residue fields. In other words, the fiber of the map from $X \times_S Y$ to the topological fiber product is precisely $\mathrm{Spec}(\kappa(x) \otimes_{\kappa(s)} \kappa(y))$ at the point $(x,y,s)$. Note that $\mathfrak{p}$ can also be equivalently described as a prime ideal $\mathfrak{q}$ in the tensor product of the local rings $\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y}$, which restricts to the maximal ideals in $\mathcal{O}_{X,x}$ and $\mathcal{O}_{Y,y}$ (and therefore also in $\mathcal{O}_{S,s}$, since $f^\#_x$ and $g^\#_y$ are local).
The topology looks as follows: If $U \times_T V$ is a basic open subset of the topological fiber product (i.e. $U \subseteq X, V \subseteq Y, T \subseteq S$ open wih $f(U) \subseteq T \supseteq g(V)$) and $f \in \mathcal{O}_X(U) \otimes_{\mathcal{O}_S(T)} \mathcal{O}_Y(V)$, then $\Omega(U,V,T,f) \subseteq X \times_S Y$ consists of those $(x,y,s,\mathfrak{q})$ such that $x \in U, y \in V, s \in T$ and that the image of $f$ in $\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y}$ is not contained in $\mathfrak{q}$. These sets form a basis for a topology on $X \times_S Y$. The structure sheaf is defined in such a way that on local rings $\mathcal{O}_{X \times_S Y,(x,y,s,\mathfrak{q})} = (\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y})_{\mathfrak{q}}$. A general section in $\mathcal{O}_{X \times_S Y}$ is a function valued in these stalks, which is locally a fraction.
Of course, all this is not needed to see that the affine line with doubled origin is not separated. And once again I cannot recommend to read Hartshorne for the basics of algebraic geometry. If $X_1$ and $X_2$ are equal affine schemes and $U$ is an open subscheme, then $X=X_1 \cup_U X_2$ is separated iff $X_1 \times_X X_2 = X_1 \cap X_2 = U$ is affine, and $U \to X_1 \times X_2$ is a closed immersion. In particular, the affine line with a doubled origin is not separated.
Best Answer
The cohomology of projective schemes can be computed by resolving the structure sheaf by twists of $\mathcal O_{\mathbb P^n}$. In the case of hypersurfaces, the resolution is especially nice, and the cohomology can be found by writing long exact sequences.
In your example, we have an exact sequence $$ 0 \to \mathcal O_{\mathbb P^ n}(-d) \to \mathcal O_{\mathbb P} \to \mathcal O_X \to 0 $$
where the left map is multiplication by $f$. Then one can take cohomology of this to compute $H^i(X,\mathcal O_X)$. We get $$ ...\to H^{i}(\mathcal O_{\mathbb P}(-d)) \to H^i(\mathcal O_{\mathbb P}) \to H^i(\mathcal O_X) \to H^{i+1}(\mathcal O_{\mathbb P}(-d)) \to ... $$
If $0 < i < n$, then $H^i(\mathcal O_{\mathbb P}(l))=0$, so we get $H^i(\mathcal O_X(k))=0$ for $0 < i < n-1$. It remains to compute $H^0(\mathcal O_{X}(k))$ and $H^{n-1}(\mathcal O_X(k))$.
We have $$ 0 \to H^0(\mathcal O_{\mathbb P}) \to H^0(\mathcal O_{X}) \to 0 $$ so $H^0(\mathcal O_{X})=1$. But twisting will give $$ 0 \to H^0(\mathcal O_{\mathbb P}(-d+k)) \to H^0(\mathcal O_{\mathbb P}(k)) \to H^0(\mathcal O_X(k)) \to 0 $$ So for $k \geq d$, we get that $H^0(\mathcal O_X(k))$ is a difference of binomial coefficients. For $k < d$, we have $H^0(\mathcal O_X(k)) \simeq H^0(\mathcal O_{\mathbb P}(k))$.
To compute the top cohomology, just reverse the previous argument (in fancy language: use Serre duality on $\mathbb P^n$ and the adjunction formula on $X$).
In general, if $X$ is defined by more than one equation, you will have to split the resolution of $\mathcal O_X$ into short exact sequences and do more work. But it all follows from the cohomology of $\mathbb P^n$ and the fact that $h^0(\mathcal O_{\mathbb P}(d))=\binom{n+d}{d}$.