0

Getting x1 is not defined on line 21 -- print(x1)

import math





global x1, x2

def x1x2():
    a = input("Please input a")
    b = input("Please input b")
    c = input("Please input c")
    minusb = b * -1
    squareroot = (b*b) - (4*a*c)
    afterroot = math.sqrt(squareroot)
    x1 = (minusb  + afterroot)/(a*2)
    x2 = (minusb - afterroot)/(a*2)
    return x1, x2;


print(x1)
print(x2)

Basically I'm trying to receive keyboard input to define a, b & c, and then using the common https://ibb.co/VghZBBs forumla to calculate the two possible answers for x, but for some reason the code isn't assigning a final value to x1, nor to x2

0 Answers0