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?



How can the ternary operators be used in python?..

Answer / 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

More Python Interview Questions

Can we use angularjs with python?

0 Answers  


Explain “with” statement in python?

0 Answers  


What is argument in a function?

0 Answers  


How do you debug a python program?

0 Answers  


What is built-in type in python?

0 Answers  


How do I sleep in python?

0 Answers  


Explain about python’s parameter passing mechanism?

0 Answers  


What is swapcase() function in the python?

0 Answers  


What is the use of break statement?

0 Answers  


How python does compile-time and run-time code checking?

0 Answers  


Is python easy to learn if you know c++?

0 Answers  


Explain how you can minimize the memcached server outages in your python development?

0 Answers  


Categories