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)

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *