How to Solve quadratic equation in python | Must Watch

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 10

  • @devamshah9361
    @devamshah9361 2 ปีที่แล้ว +7

    in 8 th line it will came 4 not 5

  • @nikosvellis4132
    @nikosvellis4132 2 ปีที่แล้ว +2

    d = d**2 -4*a*c
    Then,
    If a= 0 then the first "if" is correct and will run but you cant devide by zero.
    It needs if statement for checking the values of a.

    • @dndplus5
      @dndplus5 ปีที่แล้ว

      ok, so i'm running the the code with your corrected numbers and his input numbers. the result is X1 = 1.62; X2 = -1. is this correct?

    • @nikosvellis4132
      @nikosvellis4132 ปีที่แล้ว

      @@dndplus5 No it's not correct. From his input numbers a, b, c you should find
      X1=1.72 and X2=-0.72.

    • @dndplus5
      @dndplus5 ปีที่แล้ว

      @@nikosvellis4132 the line in question reads d = b ** 2 -4 * a * c, when I run, the output: X1 = 1.72; X2 = -1. how do I correct X2 output?

    • @dndplus5
      @dndplus5 ปีที่แล้ว +1

      I found the error, line print("X1 = %.2f; X2 = %.2f" % (x1,x2)) I failed to include the 2 in the X2 equation. code is working now.

    • @nikosvellis4132
      @nikosvellis4132 ปีที่แล้ว

      @@dndplus5 Good.
      Most important thing about his code is to check the value of "a" because you can see it won't run.
      You could also expand your code by finding also any complex roots we might have in an quadratic equation.

  • @jimslim8759
    @jimslim8759 3 ปีที่แล้ว

    Thanks very easy to understand and straightforward

  • @yechai1547
    @yechai1547 2 ปีที่แล้ว

    Thanks for ur vedio, its so clear and convenient.