What does x ^ 2 mean? in python
<p>i'm sure it's very basic and I should understand it, but I don't!</p>

<p>I'm given this to do:</p>

<pre><code>&gt; a=int(input("Enter the value for the co-efficient of x^2. "))
&gt; b=int(input("Enter the value for the co-efficient of x. "))
&gt; c=int(input("Enter the value for the constant term. ")) s=b**2-4*a*c
&gt; x1=(-b+(s**(1/2)))/2*a x2=(-b-(s**(1/2)))/2*a if a==0 and b==0:
&gt;     print("The equation has no roots.") elif a==0:
&gt;     print("The equation has only one root and it is", -c/b) elif s&lt;0:
&gt;     print("The roots are not real!") else:
&gt;     print("The roots are", x1, "and", x2)
</code></pre>

<p>I get the right solution and everything right but I have no idea what the ^  is there for. The only reason I used it is because it was used in the other example during the lesson before the practice!</p>

<p>It doesn't 'mean' anything, not to Python; it is just another character in a string literal:</p>

<pre><code>"Enter the value for the co-efficient of x^2. "
</code></pre>

<p>You could have written something else:</p>

<pre><code>"Enter the value for the co-efficient of x to the power 2. "
</code></pre>

<p>and nothing but the output shown when asking for <code>input()</code> would have changed.</p>

<p><code>^</code> is a common notation for exponents. In Python, <code>**</code> is used for exponents, and that is what the rest of the code uses.</p>

python python-3.x