No Title - Different type of 'error'? (True, False)

a, b in RealNumber, it should be always ‘TRUE’…

a > (a+b)/2 > b AND a**2 + b**2 >= 2*a*b

But, why ‘False’?

r = range

A = {(a > (a+b)/2 > b) is True
     for a in r(-10, 10)
     for b in r(-10, 10)
     }
print(A)

 >> {False, True}  # should be only True

B = {(a**2 + b**2 >= 2*a*b) == True
     for a in r(-100, 100)
     for b in r(-100, 100)
     }
print(B)

>> {True}

A different try:

C = {True if (a**2 + b**2 >= 2*a*b) else False
     for a in r(-100, 100)
     for b in r(-100, 10)}
print(C)

D = {True if (a > (a+b)/2 > b) else False
     for a in r(-10, 10)
     for b in r(-10, 10)
     }
print(D)

What if a is less than b?

You are correct. I did, in fact, include those restrictions. Inspect these two scripts.

added a > b

C = {True if (a**2 + b**2 >= 2*a*b and a > b) else False
     for a in r(-100, 100)
     for b in r(-100, 10)}
print(C)

Another version of Script:

D = {True if all(a > (a+b)/2 > b
                 for a in r(-10, 10)
                 for b in r(-10, 10)
                 if a > b & a!=0 & b!=0)
     else False
     }
print(D)

Please stop these posts. Learn to debug. Don’t assume, but verify. Just simply put in same value for a and b and you’ll see.

Anyway, don’t keep posting these pointless topics.

1 Like