How to fix 'ValueError: math domain error' in python?
问题 I am trying to write a program which calculates formula y=√x*x + 3*x - 500, Interval is [x1;x2] and f.e x1=15, x2=25. I tried to use Exception Handling but it didn't help. And the code I try to use now gives me: ValueError: math domain error import math x1 = int(input("Enter first number:")) x2 = int(input("Enter second number:")) print(" x", " y") for x in range(x1, x2): formula = math.sqrt(x * x + 3 * x - 500) if formula < 0: print("square root cant be negative") print(x, round(formula, 2))