# CodeStepByStep

## if_else_translation

Language/Type: Python boolean logic expressions

Translate each of the following English statements into logical tests that could be used in an `if/else` statement. Write the appropriate logical test for each statement below. Assume that three `int` variables, `x`, `y`, and `z`, have already been declared.

 z is odd ``` z == 2 ``` ``` z // 2 == 0 ``` ``` z % 2 != 0 ``` ``` z * 2 == 0 ``` ``` z % 2 == 0 ``` (order shuffled) z is not greater than y's square root ``` z <= math.sqrt(y) ``` ``` !z > y * y ``` ``` z > math.sqrt(y) ``` ``` z * z < y ``` ``` z !> sqrt(y) ``` (order shuffled) y is positive ``` y > 0 ``` ``` y >= 0 ``` ``` y < 0 ``` ``` y != 0 ``` ``` y == 0 ``` (order shuffled) Either x or y is even, and the other is odd ``` y % 2 == x % 2 ``` ``` (x + y) % 2 == 0 ``` ``` x % 2 != y % 2 ``` ``` x % 2 == 0 or y % 2 != 0 or x % 2 != 0 or y % 2 == 0 ``` ``` x % 2 == 0 and y % 2 == 1 and x % 2 == 1 and y % 2 == 0 ``` (order shuffled) y is a multiple of z ``` y - z == 0 ``` ``` y % z == 0 ``` ``` y // z == 0 ``` ``` y // z != 0 ``` ``` z % y == 0 ``` (order shuffled) z is not zero ``` z <> 0 ``` ``` z >< 0 ``` ``` z != 0 ``` ``` z < 0 and z > 0 ``` ``` !z == 0 ``` (order shuffled) y is greater in magnitude than z ``` y < math.abs(z) ``` ``` math.abs(y) > math.abs(z) ``` ``` y > z or y < z ``` ``` y > z and y < z ``` ``` math.abs(y) > z ``` (order shuffled) x and z are of opposite signs ``` x * z < 0 ``` ``` x < 0 and z > 0 ``` ``` (x < 0) == (z < 0) ``` ``` x < 0 or z < 0 ``` ``` x >= 0 and z < 0 ``` (order shuffled) y is a nonnegative one-digit number ``` 10 % y == 0 ``` ``` y == y % 10 ``` ``` y > 10 ``` ``` y // 10 != 0 ``` ``` y == y // 10 ``` (order shuffled) z is nonnegative. ``` z // 0 == 1 ``` ``` z < 0 ``` ``` z >= 0 ``` ``` z != 0 ``` ``` z % 0 < 0 ``` (order shuffled) x is even ``` x > 0 ``` ``` x % 10 != 0 ``` ``` x % 2 == 0 ``` ``` x // 2 == 0 ``` ``` x % 2 == 1 ``` (order shuffled) x is closer in value to y than z is ``` y - x == z ``` ``` math.abs(x - y) < math.abs(z - y) ``` ``` x - y < z ``` ``` math.abs(x - y - z) < 0 ``` ``` y - x < z - x ``` (order shuffled)