Sign Check

This function helps you practice conditions with number signs and an extra flag that changes the rule. Write a function pos_neg that takes two non-zero numbers a and b, plus the boolean flag negative. If negative is False, return True when one number is positive and the other is negative. If negative is True, return True only when both numbers are negative.

Примеры

Ввод
1, -1, False
Вывод
True
Ввод
-1, 1, False
Вывод
True
Ввод
-4, -5, True
Вывод
True

Нужно реализовать

def pos_neg(a: int, b: int, negative: bool) -> bool:

Теги

math
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
1, -1, False
ExpectedTrue
2
Input
-1, 1, False
ExpectedTrue
3
Input
-4, -5, True
ExpectedTrue
4
Input
-4, -5, False
ExpectedFalse
5
Input
1, 1, False
ExpectedFalse
6
Input
-1, 5, True
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid