Ternary operator Ternary operator also known as conditional expression operator. Checks for the condition and then evaluates true or false. It has very simple syntax of single with (if else) conditional statements. Syntax of ternary operator : [true_statement] if [expression] else[false_statement] Voter eligibility using ternary operator Read age from the user. follow syntax Program on voter eligibility using ternary operator in python. Input : enter your age 16 Output : You are not eligible. # program to print voter eligibility using ternary operator age=int(input("enter your age ")) print("You are eligible"if age>18 else "You are not eligible") Output : enter your age 16 You are not eligible.
Programming for everybody...