Python Online Compiler
Example: Python Program to Check If a Number is Odd or Even using Ternary Operator
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Check If a Number is Odd or Even using Ternary Operator print ("Enter an integer number to check:\n") x = int (input ()) x = 1 if x % 2 == 0 else 0 if (x): print ("The input number is even.\n") else: print ("The input number is odd.\n")
35
Output
Clear
ADVERTISEMENTS