Sign Mode

This check works like a mode switch: the normal rule is one thing, and the special flag changes it. Write a function pos_neg that takes two integers a and b, plus the boolean flag negative. If negative is False, return True when exactly one number 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

Tu sa zobrazí výsledok spustenia kódu

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, -1, False
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid