d = b**2-4*a*c # discriminant if d < 0: print ("This equation has no real solution") elif d == 0: x = (-b+math.sqrt(b**2-4*a*c))/2*a print ("This equation has one solutions: "), x else: x1 = (-b+math.sqrt((b**2)-(4*(a*c))))/(2*a) x2 = (-b-math.sqrt((b**2)-(4*(a*c))))/(2*a) print ("This equation has two solutions: ", x1, " or", x2)
The python math module doesn't have an abs function as this functionality is provided by basic Python. However, looking at the documentation page for python math here you can see that they do in fact have a fabs function.
In maths, if I wish to calculate 3 to the power of 2 then no symbol is required, but I write the 2 small: 3². In Python this operation seems to be represented by the ** syntax. >>> 3**2 9 ...
Is there a difference in the results returned by Python's built-in pow(x, y) (no third argument) and the values returned by math.pow(), in the case of two float arguments. I am asking this question
The math module and math.ceil() is in the standard library, so available everywhere for all practical purposes without installing extra stuff. And regarding your mention of when it fails, this is incomplete in your answer, as it fails for a whole interval, not just for a single point.
Apologies if this is straight forward, but I have not found any help in the python manual or google. I am trying to find the inverse cosine for a value using python.
41 I am trying to calculate the inverse of tan in python, but it does not give me the correct value, for example, if I were to do the inverse tan of 1.18, math.atan(1.18)