## current position：Home>Python----solve quadratic equation in one variable

# Python----solve quadratic equation in one variable

2022-11-08 07:20:06【will be open today】

**No wrapper version**

`import matha,b,c=eval(input())#tupleif a!=0:d=b*b-4^a^cif d>0:x1=-b/(2*a)+math.sqrt(d)/(2*a)x1 = -b / (2 * a) - math.sqrt(d) / (2 * a)print("x1={},x2={}".format(x1,x2))elif d==0:x1=x2=-b/(2*a)print("x1={},x2={}".format(x1,x2))else:real=-b/(2*a)imag=math. sqrt(-d)x1=complex(real,imag)x2=complex(real,-imag)print("x1={},x2={}".format(x1,x2))else:print("Not a quadratic equation")`

**Package version**

`import mathdef root(a,b,c):d=b*b-4*a*cif d>0:x1=-b/(2*a)+math.sqrt(d)/(2*a)x2 = -b / (2 * a) - math.sqrt(d) / (2 * a)elif d==0:x1=x2=-b/(2*a)else:real=round(-b/(2*a),2)#round(x,y): rounding functionimag=round(math.sqrt(-d),2)x1=complex(real,imag)x2=complex(real,-imag)return x1,x2def main():a,b,c=eval(input())x1,x2=root(a,b,c)print("x1={},x2={}".format(x1,x2))main()`

copyright notice

author[will be open today],Please bring the original link to reprint, thank you.

https://en.pythonmana.com/2022/312/202211080628358099.html

## The sidebar is recommended

- I wrote a financial data crawler in Python, and I did the work of the interns for a week in half an hour
- Python project combat - bank ATM system (3)
- Python decimal to binary function_python hexadecimal to binary
- Python toolbox series (12)
- python automatic send mail script
- [Study Notes] Introduction to Deep Learning: Theory and Implementation Based on Python
- How python handles program exceptions
- Python Volunteer Management System Based on PHP+MySQL
- python is based on PHP+MySQL university asset management system
- Python is based on PHP+MySQL reading sharing platform

## guess what you like

Python student association management system based on PHP+MySQL

Notes for python importing other modules under windows

What exactly does Python's __pycache__ cache?Can the historical running results be cached?- A little research on PyCache

Compare similarity of two vectors - python

Boutique flower sales shopping mall applet based on Python

python get all files in current directory

python gets computer CPU, motherboard, BIOS, hard disk serial number, host name, IP, Mac address

python get computer unique identifier

Python converts strings to hexadecimal (encryption and decryption)

python based on PHP+MySQL college students job recruitment website

## Random recommended

- Linear sieve prime number template (Python/C++)
- python university student health management system based on PHP+MySQL
- Python Deep Learning in Action: Testing Neural Networks
- UE4 gets HTTP interface data (UE4 communicates with python)
- Ask a complex text processing problem Python
- Talking about list creation and list element addition and deletion in Python
- Python finds the average mutual information of English text
- Python performance optimization example exercise
- python script rewrite yaml
- Python NotImplementedError: cannot instantiate 'PosixPath' on your system
- How far can a Python novice learn to do automation?
- [Bluebridge Cup for Python] day_008: Huffuman tree
- Install the GDAL library in Python
- Python classic questions finishing
- Python - function design and use
- October 2022 Python Cabin Programming Contest Winners List (Free 5 Books)
- Introduction to Python Interesting Algorithms - Newton's Iterative Method to Find Equation Roots
- Introduction to Python Fun Algorithms - Catch Traffic Accidents & Best Deposit Schemes
- Introduction to Interesting Algorithms in Python - How Much Do You Know About Borrowing Solutions
- Python writes a small game: snake chess (below)
- Introduction to Python Interesting Algorithms - Rabbit Childbirth (Intrinsic Logic of Fibonacci Sequences)
- Getting Started with Interesting Algorithms in Python Develop Paper
- Upgrading Python Packages with Pip
- Python extracts video frames and saves them as images - target detection
- To revisit the Python list base - operation
- {0:2d} {1:3d} {2:4d}'.format(x, x * x, x * x * x) understanding in Python
- Python's pickle method for simple information management
- Python basic exercises (4)
- Python basic exercises (3)
- The pushback of python scrolling at any point in time
- Revisiting Python Basics - Numbers
- python: basics
- Object-Oriented Polymorphism in Python
- Python basics (suitable for beginners - complete tutorial - learning time for about a week - saving your time)
- Python foundation 05 - dictionary: dict and set: set, reading this article is enough
- After learning JsonPath, your Python interface script is complete
- The three main modules of Python that novice Xiaobai should know
- Install python3.8.9 in Linux environment
- Python---- Monte Carlo method to find Π, stopwatch function
- Python----scientific notation, assigning multiple variables at the same time, eval function, math library function, complex number (complex()), built-in numerical operation function, built-in numerical operation operator