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
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
1, -1, FalseExpected
True2
Input
-1, 1, FalseExpected
True3
Input
-4, -5, TrueExpected
True4
Input
-4, -5, FalseExpected
False5
Input
1, 1, FalseExpected
False6
Input
-1, -1, FalseExpected
FalseFocus radio
Paused · SomaFM · Fluid