Site icon DataFlair

Ternary Operator in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

#n=int(input("Enter a number"))
#print("Hello") if(n>100) else print("Bye")

# Program for +ive and -ive

#n=int(input("Enter a number"))
#print("No is +ive") if(n>=0) else print("No is -ive")


# Program for Even and Odd

#n=int(input("Enter a number"))
#print("No is Even") if(n%2==0) else print("No is Odd")


# Program for Greater between 2 No

#a=int(input("Enter first number"))
#b=int(input("Enter second number"))

#print("Greater No is ",a) if(a>b) else print("Greater No is ",b)

#Program for Greater between 3 Nos

a=int(input("Enter First number"))
b=int(input("Enter Second number"))
c=int(input("Enter  Third number"))

print("Greater No is",a) if(a>b and a>c) else print("Greater No is",b) if(b>c) else print("Greater No is",c)

 

Exit mobile version