DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Conditionals — Example 64

Quick explanation + ready code for: Conditionals.

Python Conditionals Back to examples
Back to language
Syntax: Conditionals in Python. ID: #64

Code

n = 12
print("even" if n % 2 == 0 else "odd")

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.