예제 #1
0
def selesaikanABC(a,b,c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = float(b**2 - 4*a*c)
    if (D<0):
        hasil = "Determinannya negatif, persamaan tidak mempunyai akar real."
        return hasil
    else:
        x1 = (-b + akar(D))/(2*a)
        x2 = (-b - akar(D))/(2*a)
        hasil = (x1,x2)
        return hasil
예제 #2
0
def selesaikanABC(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = (b**2) - (4 * a * c)

    if D < 0:
        return "Determinannya negatif. Persamaan tidak mempunyai akar real."
    else:
        x1 = (-b + akar(D)) / (2 * a)
        x2 = (-b - akar(D)) / (2 * a)
        hasil = (x1, x2)
        return hasil
def selesaikanABC(abc):
    abc = abc.split(",")
    a = float(abc[0])
    b = float(abc[1])
    c = float(abc[2])
    D = b**2 - 4 * a * c
    if D < 0:
        return print(
            "Determinannya negatif. Persamaan tidak mempunyai akar real.")
    else:
        x1 = (-b + akar(D)) / (2 * a)
        x2 = (-b - akar(D)) / (2 * a)
        hasil = (x1, x2)
        return print("Hasil = " + str(hasil))
예제 #4
0
def selesaikanABC(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = b**2 - 4 * a * c

    if D > 0:
        x1 = (-b + akar(D)) / (2 * a)
        x2 = (-b - akar(D)) / (2 * a)

        hasil = (x1, x2)
        return hasil

    else:
        print("Determinannya negatif. Persamaan tidak mempunyai akar real")
def faktorPrima(x):
    Hasil = []
    for i in range(2, (int(akar(x)) + 1)):
        while x % i == 0:
            x = x // i
            Hasil.append(i)
        if apakahPrima(x) == True:
            Hasil.append(x)
            break
    return Hasil
def apakahPrima(x):
    n = int(x)
    assert n >= 0
    if n in [2, 3, 5, 7, 11]:
        return True
    elif n in [0, 1, 4, 6, 8, 9, 10]:
        return False
    else:
        for i in range(2, int(akar(n) + 1)):
            if n % i == 0:
                return False  # Jika n modulo i sama dengan 0 kembalikan False
        return True
예제 #7
0
def selesaikanABC(a, b, c):
    D = float(b**2 - 4 * a * c)
    return ("Determinan negatif, Persamaan tidak memiliki akar real"
            if D < 0 else ((-b + akar(D)) / (2 * a), (-b - akar(D)) / (2 * a)))