[Python] Why does my TI-84 Plus CE calculator say there's an error on line 13 when it works...

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple program to get me the answer of a quadratic formula.

    import math

    def solve_quadratic(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)

    d = b**2 - 4*a*c
    if d < 0:
    print("No real roots")
    elif d == 0:
    x = -b / (2*a)
    print(f"x = {x}") # line 13
    else:
    x1 = (-b + math.sqrt(d)) / (2*a)
    x2 = (-b - math.sqrt(d)) / (2*a)
    print(f"x = {x1}, {x2}")

    while True:
    solve_quadratic(input("a = ? "), input("b = ? "), input("c = ? "))


    On VS Code, it works completely fine, but for my calculator, it says there's an error on line 13.

    >>> SyntaxError: invalid syntax


    How can I fix this?

    Continue reading...

Compartilhe esta Página