Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can the ternary operators be used in python?

Answer Posted / chaitanya

The ternary operator is the operator that is used to show the conditional statements. This consists of the true or false values with a statement that has to be evaluated for it. The operator will be given as:

[on_true] if [expression] else [on_false]

x, y = 25, 50

big = x if x < y else y

This is the lowest priority operator that is used in making a decision that is based on the values of true or false. The expression gets evaluated like if x<y else y, in this case if x<y is true then the value is returned as big=x and if it is incorrect then big=y will be sent as a result.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is python metaclass?

1184


What is a python mixin?

965


What is encapsulation in python?

901


Which gui is best for python?

871


How do you call functions in python?

1123


Is python or r more useful?

868


Is there a tool to help find bugs or perform static analysis?

894


Explain the difference between append vs extend in list?

967


What is mro in python?

952


What are the programming-language features of python?

992


Explain about the use of python for web programming?

939


How do you split a list into evenly sized chunks?

907


What is python orm?

981


How will you capitalize the first letter of string?

1629


What does “list comprehension” mean? How does it work and how can I use it?

899