Search⌘ K
AI Features

Solution Review: Check if Even or Odd

Explore how to use conditional statements in Python and PowerShell to check if a number is even or odd. This lesson helps you understand the core logic in both languages, focusing on the use of modulus and conditional branching to control program flow.

Solution

Let’s understand the solution of the challenge in Powershell and Python.

Python

Python 3.5
number= 10 # Check if this number is odd or even
if (number%2) == 0:
print("The number is even")
else:
print("The number is odd")

Explanation

  • We have only two conditions as output,
...