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
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible 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