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
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible 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, 5, TrueExpected
FalseFocus radio
Paused · SomaFM · Fluid