Opposite Signs Checker
Отборная информация, которая вставляет!
Дата публикации: 17.07.2025

Opposite Signs Checker


Python code:

def check_opposite_signs(a, b):
    if (a < 0 and b > 0) or (a > 0 and b < 0):
        return True
    else:
        return False

# Test cases
print(check_opposite_signs(-3, 4))       # True
print(check_opposite_signs(4, 3))        # False
print(check_opposite_signs(0, 4))        # False
print(check_opposite_signs(8, 0))        # False
print(check_opposite_signs(0, -4))       # False
print(check_opposite_signs(-4, -8))      # False
print(check_opposite_signs(20000, -20001))   # True
print(check_opposite_signs(0, 0))        # False

Explanation:

  • The function check_opposite_signs takes two integers a and b as input.
  • It checks if a is negative and b is positive, or if a is positive and b is negative.
  • If either of these conditions is true, it returns True, indicating that the numbers have opposite signs.
  • Otherwise, it returns False.
  • The test cases demonstrate the expected output for different combinations of numbers.
Bezpenostn tipy pro chatovn s neznmmi na Rulette