Categories:Viewed: 3 - Published at: a few seconds ago

Write a function to return the product of the roots of a quadratic equation ax**2 + bx + c = 0

def prod_of_roots(a:float,b:float):
    if a:
        return -b/a
    else:
        return None

Write a function to return the real of the roots of a quadratic equation else return None ax**2 + bx + c = 0

def roots_of_qad_eq(a:float,b:float,c:float):
    d = b**2-4*a*c
    if d >= 0:
        return (-b+(d)**(1/2))/2*a,(-b-(d)**(1/2))/2*a
    else:
        return None

Write a function to return the profit or loss based on cost price and selling price

def find_profit_or_loss(cp,sp):
    if cp > sp:
        return 'loss', cp-sp
    elif cp < sp:
        return 'profit', sp-cp
    else:
        return 'no profit or loss', 0