I have gotten a little confused about the notation regarding line bundles and their holomorphic sections on projective spaces, and subsequently projective varieties, as well as the meaning of $\mathcal{O}_X$. (My background is more in physics than algebraic geometry).
Let me start with line bundles on $\mathbb{P}^n$. These can be denoted by $\mathcal{O}_{\mathbb{P}^n}(k)$, for $k\in \mathbb{Z}$. There are various ways to arrive at this description, I think the standard method is to define the tautological line bundle -- where the fibre over $p\in\mathbb{P}^n$ is the line in $\mathbb{C}^n$ described by $p$ -- by $\mathcal{O}_{\mathbb{P}^n}(-1)$, and its dual, the hyperplane bundle, as $\mathcal{O}_{\mathbb{P}^n}(1)$, and then denote $$ \mathcal{O}_{\mathbb{P}^n}(k) = \mathcal{O}_{\mathbb{P}^n}(1)^{\otimes k}, \quad k\geq1 $$ $$ \mathcal{O}_{\mathbb{P}^n}(-k) = \mathcal{O}_{\mathbb{P}^n}(-1)^{\otimes k}, \quad k\geq1 $$
We can also denote by $\mathcal{O}_{\mathbb{P}^n} = \mathcal{O}_{\mathbb{P}^n}(0)$ the trivial bundle on $\mathbb{P}^n$, with the property that $\mathcal{O}_{\mathbb{P}^n}(k)\otimes\mathcal{O}_{\mathbb{P}^n}(-k) = \mathcal{O}_{\mathbb{P}^n}$. The tensor product then gives the space of line bundles the structure of an Abelian group, $Pic(\mathbb{P^n})=\mathbb{Z}$.
I believe that for a projective hypersurface $Y \subset \mathbb{P}^n$, ignoring any special cases, this notation can be carried over to line bundles on $Y$.
Question 1 Is this statement more generally true, for higher codimension varieties $Y$ in $\mathbb{P}^n$? (via e.g. some Lefschetz theorem?)
Now for a given complex manifold $X$, we can associate to $X$ the structure sheaf $\mathcal{O}_X$, which is the sheaf of local holomorphic functions on $X$. I understand that there is a relationship between the space of sections of a vector bundle and a particular locally free sheaf.
Question 2 Can we directly associate $\mathcal{O}_X$ with a line bundle on $X$? Is there some statement about the degrees of the sections of this line bundle?
Question 3 I believe the sections of $\mathcal{O}_{\mathbb{P}^n}(k)$, which are elements in $H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(k))$, are homogeneous polynomials of degree $k$. This should mean that sections of $\mathcal{O}_{\mathbb{P}^n}$ are locally constant polynomials. The previous should then be true for $Y\subset \mathbb{P}^n$, so that $H^0(Y, \mathcal{O}_Y)$ is the space of locally constant polynomials on $Y$. Is this the case, and in general can we classify line bundles on projective varieties based on the degrees of their sections? Or is the more fundamental object the 'cocycle' associated with the transition functions of the local trivialization (for $\mathcal{O}_{\mathbb{P}^n}(k)$ these are the $k$-th power of the transition functions of $\mathcal{O}_{\mathbb{P}^n}(1)$)?
Question 4 Is it correct to call the sheaf of sections of $\mathcal{O}_{\mathbb{P}^n}$ the structure sheaf of $\mathbb{P}^n$? How can this be if $\mathcal{O}_X$ is supposed to include all holomorphic functions, not just locally constant ones? In particular my confusion arises in the description of the exponential sequence, where the locally constant sheaf is called $\mathbf{Z}$, what is this objects relation to line bundles? (... of course this could just refer to the sheaf of integer valued functions?)
Sorry for the length, I believe these are all essentially different versions of the same question: what is the relationship of $\mathcal{O}_X$ to line bundles and sections of line bundles on $X$. My confusion arises because in the literature there are (with good reason) jumps between the sheaf description and the vector/line bundle description.