I want to convert this code, which is to solve the quadratic equation, into a lambda function

```from math import sqrt
def Equation(a,b,c):
r = b ** 2 - 4 * a * c
if r > 0:
num_roots = 2
x1 = (((-b) + sqrt(r)) / (2 * a))
x2 = (((-b) - sqrt(r)) / (2 * a))
print("There are 2 roots: %f and %f" % (x1, x2))
elif r == 0:
num_roots = 1
x = (-b) / 2 * a
print("There is one root: ", x)
else:
num_roots = 0
print("No roots, discriminant < 0.")

Equation(1,2,0)``` Jul 11, 2020 in Python 1,971 views

## 1 answer to this question.

Hello @ Ø§Ù…ÛŒØ±Ø­Ù…Ø²Ù‡ ,

```from math import sqrt

Root = lambda a, b, c: ((-b + sqrt((b * b) - (4 * a * c))) / (2 * a), (-b - sqrt((b * b) - (4 * a * c))) / (2 * a))

print(Root(1,2,0))      # call the lambda function```

Hope it helps!!
Thank You!! answered Jul 13, 2020 by
• 82,740 points

## How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

+1 vote

## What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

## Which are the tools which can be used to produce documentation for a REST API automatically using Python in Flask?

Hi, good question. There is a module meant ...READ MORE

## How Lambda() is used with filter() in python?

The filter() function in Python takes in ...READ MORE

## What is the purpose of using lambda functions in Python?

The main purpose of anonymous functions come ...READ MORE

## Using lambda functions to solve Algebra

Python lambda functions can be used to ...READ MORE

## Why are Python lambdas useful?

The main purpose of anonymous functions come ...READ MORE