How to find the square root in Python
Python how to find the square root, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
1. Open the IDLE,File--New File of python and create a new file
2. Enter the code in the empty file, File--Save, or Ctrl+s to save the file anywhere on the computer, press the keyboard F5 directly, or Run--Run Module to execute the code.
3. when running, enter a, b, c and press enter on the keyboard to get the following result
Second, code analysis
D = (breadbasket 2)-(4*a*c)
That is, d equals the square of b minus 4ac
Sol1 = (- b-cmath.sqrt (d)) / (2yoga)
According to the direct calculation of mathematical publicity, sqrt is the square root function.
Print ('result is {0} and {1}' .format (sol1,sol2))
Output the corresponding sol1 and sol2
Matters needing attention
1. When entering each line of code, each line must be aligned, and if there are spaces, the number of spaces must be the same.
2, pay attention to the double quotation marks "", where the double quotation marks function is the same as the single quotation marks, must be in the English input method, can not be entered under the Chinese input method, otherwise the program will run error.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.