PROBLEM 39
Easy

Different Signs

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#39

Given two non-zero integers `a`, `b`, print `YES` if their signs differ, else `NO`.

EXAMPLE

Example

Input
4 -9
Output
YES

LIMITS

Constraints

a ≠ 0; b ≠ 0
📖
LEARN Theory for this problem
+

`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `and` requires all combined conditions to be true. `or` requires at least one condition to be true. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.

**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `'YES'` shows how this idea is applied to the task data.

For this task, pay special attention to `map(int, input().split())`: it connects the concept above to the concrete computation or program action.

**Focus: “Different Signs”.** The same basic mechanism is used in a different context here, so understand the operation itself rather than memorizing a finished line of code.

💡
NEED HELP? Hints
+

['One must be positive and the other negative.']

ANSWER Solution
+
a, b = map(int, input().split())
if a > 0 and b < 0 or (a < 0 and b > 0):
    print('YES')
else:
    print('NO')