{"id":5044,"date":"2023-09-08T04:41:48","date_gmt":"2023-09-08T03:41:48","guid":{"rendered":"https:\/\/statanalytica.com\/blog\/?p=5044"},"modified":"2023-12-29T11:40:14","modified_gmt":"2023-12-29T11:40:14","slug":"ternary-operator-in-python","status":"publish","type":"post","link":"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/","title":{"rendered":"How To Use Ternary Operator in Python With Examples"},"content":{"rendered":"\n<p>Python is an essential programming language nowadays. Python&#8217;s popularity is increasing by the day. So there are several basic python issues where students get confused, such as tuple in Python, <a href=\"https:\/\/statanalytica.com\/blog\/linked-list-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python linked list<\/a>, ternary operators, etc. So many students search for a solution on the internet. So in this blog, we will discuss ternary operator in Python With programs. Keep reading to clear your doubts related to python ternary operators.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"let-us-start-with-what-are-ternary-operators\"><\/span><strong>Let us Start With What Are Ternary Operators<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a04d267a2421\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ff5104;color:#ff5104\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ff5104;color:#ff5104\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a04d267a2421\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#let-us-start-with-what-are-ternary-operators\" >Let us Start With What Are Ternary Operators<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#python-conditionals\" >Python conditionals<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#ternary-operator-in-python\" >Ternary Operator in python<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#syntax\" >Syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#the-ternary-operator-can-be-expressed-as-a-nested-if-else-statement\" >The ternary operator can be expressed as a nested if-else statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#let-us-take-a-simple-method-to-use-the-ternary-operator-in-python\" >Let us take a simple method to use the ternary operator in python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#return-value-using-the-ternary-operator\" >Return value using the Ternary Operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#a-tuple-is-used-to-do-ternary-operations\" >A tuple is used to do ternary operations.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#therefore\" >Therefore:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#in-the-tuple-make-sure-the-false-value-is-at-index-0-and-the-true-value-is-at-index-1\" >In the tuple, make sure the false value is at index 0, and the true value is at index 1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#the-syntax-for-a-list-based-ternary-operation\" >The syntax for a list-based ternary operation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#the-syntax-for-using-a-dictionary-in-a-ternary-operation\" >The syntax for using a dictionary in a ternary operation.<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#points-to-remember\" >Points to Remember:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#also-read\" >Also Read..!!<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#conclusion\" >Conclusion<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#faqs-frequently-asked-questions\" >FAQ&#8217;s (Frequently Asked Questions)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#what-are-the-benefits-of-utilizing-pythons-ternary-operator\" >What are the benefits of utilizing Python&#8217;s ternary operator?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/statanalytica.com\/blog\/ternary-operator-in-python\/#in-python-how-can-we-use-the-ternary-operator\" >In Python, how can we use the ternary operator?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>The ternary operator in Python is used to determine if a condition is true or false. The ternary operator requires one line of code, making it more compact than a full if-else expression.<\/p>\n\n\n\n<p>You can regulate the flow of your program using conditional statements, such as if statements. The code inside conditional expressions runs when a specific condition (or a collection of events) is met.<\/p>\n\n\n\n<p>The most frequent approach to express a conditional statement in Python is to use the if keyword. On the other hand, the ternary operator allows you to test a condition on a single language line. Let&#8217;s go through the fundamentals of conditional statements and how to use the ternary operator in python.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"python-conditionals\"><\/span><strong>Python conditionals<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You may only want a line or a block of code to be executed when a condition is met when writing a program. In Python, conditional statements can be used to perform this task.<\/p>\n\n\n\n<p>The if statement in Python is used to see if a condition is met with the desired output. Assume we create an app that determines whether a customer qualifies for a 20% discount at a department shop. A discount should be granted to customers who are 60 years old or older. Otherwise, he should not be offered a discount. Here we can use the if-else statement could be to create this program. If you need to evaluate a few criteria, the ternary operator in Python is a more efficient method to write an if statement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ternary-operator-in-python\"><\/span><strong>Ternary Operator in python<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>It simply replaces the multiline, if-else, with a single line to test a condition, making the code more concise.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"syntax\"><\/span><strong>Syntax<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>[when_true] &nbsp; if [expression] &nbsp; else &nbsp; [when_false]<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"the-ternary-operator-can-be-expressed-as-a-nested-if-else-statement\"><\/span><strong>The ternary operator can be expressed as a nested if-else statement<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/a-sGwkEFa6Y4xzrykmkEpmTOWhiWmj3vA45hyq3PmPKjVTd6JulFWAbEe-r7y88oOrfVST-PiFOIoaNSqyq37fq5YQPrX5_zQOzEz6H93ScW9j4RFlERJyDXbEc7toATVbx1fTs-\" alt=\"\"\/><figcaption>Ternary Operator In Python<\/figcaption><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"let-us-take-a-simple-method-to-use-the-ternary-operator-in-python\"><\/span><strong>Let us take a simple method to use the ternary operator in python<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/Gwp6azNdED-M74lF8iQtXFL8UJcBgN3OJoKurxjY7Tmz_fNoVziCkqW_mHrp8ums6EvYngd6rcaqfjgLpx1wSb0lQPjTF3gSyBSpdqKHomWnPpcR-MWjUj-f0kW_SksRWeGv84Io\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"return-value-using-the-ternary-operator\"><\/span><strong>Return value using the Ternary Operator<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>We can also employ ternary operators in the return statement within our functions. We can, for example, build a function that checks whether an integer is even or odd and returns the text &#8216;even&#8217; or &#8216;odd&#8217;:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"a-tuple-is-used-to-do-ternary-operations\"><\/span><strong>A tuple is used to do ternary operations.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>A tuple is another technique to do ternary operations in Python. This is a simple alternative to the ternary operator if-else.<\/p>\n\n\n\n<p>The two members of the <a href=\"https:\/\/statanalytica.com\/blog\/python-what-is-a-tuple\/\" target=\"_blank\" rel=\"noreferrer noopener\">Tuple<\/a> in this scenario are false value and true value. Instead of an index, the conditional expression is enclosed in square brackets. This works because True has a value of 1, and False has a value of 0.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"therefore\"><\/span><strong>Therefore:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>The value of the conditional expression becomes if it evaluates to True.<\/li><li>The ternary expression then returns the element at index 1.<\/li><li>The value of the conditional expression becomes 0 if it evaluates to False.<\/li><li>The element with index 0 is then returned.<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"in-the-tuple-make-sure-the-false-value-is-at-index-0-and-the-true-value-is-at-index-1\"><\/span><strong>In the tuple, make sure the false value is at index 0, and the true value is at index 1<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/6lrlUHKndMDoXfrS_3t36GbrwWElMXMDApI7mwbpqc_HKVjfFjo7eUVGZqn-fbqGkWChJR2-yA1UGtBLaW18Z9wFLRGZYV-rBelVCf9cNhMewRrpaEKBBrLdROI6EeSo7230DcSj\" alt=\"\" width=\"1029\" height=\"359\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"the-syntax-for-a-list-based-ternary-operation\"><\/span><strong>The syntax for a list-based ternary operation<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>As we all know in python we use [] brackets to make a list. As you can see in the given figure below. We have simply performed the ternary function on the list.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/2rG0AJWOmQ3xXfshbkU1av1CNrgiNGMIpFPXae4_J0uWl7wPaw0aex6M2U8q8WavCWXBR_nMdwfn_T6ImsxvQDm2oERHwGGDP_4CwK6iPhsMkciuXJjsJNWmdcZovFZFd6ps2Iuo\" alt=\"\" width=\"1028\" height=\"364\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"the-syntax-for-using-a-dictionary-in-a-ternary-operation\"><\/span><strong>The syntax for using a dictionary in a ternary operation.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Accordingly, the keys True and False are given true and false values. The value equivalent to True is returned if the conditional expression evaluates to True. Otherwise, the value associated with False is returned.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/hklG7HWTCsUysJOb2n7FpLOhRuH0BLc7ClF4_rOWeVeDWykzAre2YHdEXe7MhUf87YeeSnhRGe4IaIuZWLDH-fwNUezMvT8ktfJrS8ivaS67sbp-WVN2Mh3hjrrwJTF02VUxnz39\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"points-to-remember\"><\/span><strong>Points to Remember:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>In comparison to other languages, the order of the parameters in the operator is different.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Among all Python operations, conditional expressions have the lowest priority.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Simple if statements can be performed more quickly with the Python ternary operator. The ternary operator analyses a condition before returning a value based on whether the condition is True or False.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>We were able to run an if statement on one line in the examples above. This is more compact than the several lines that an if statement usually requires. On the other hand, the ternary operator in python cannot always be applied. You should write a whole if statement to test for numerous expressions. This will make your code more readable and understandable.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"also-read\"><\/span><strong>Also Read..!!<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/statanalytica.com\/blog\/python-projects-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">24 Best-Ever Python Projects for Beginners \u2013 Step by Step<\/a><\/li><li><a href=\"https:\/\/statanalytica.com\/blog\/python-array\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python Array: A Step By Step Guide With Examples For Beginners<\/a><\/li><li><a href=\"https:\/\/statanalytica.com\/blog\/python-packages-for-data-science\/\" target=\"_blank\" rel=\"noreferrer noopener\">Top Python Packages for Data Science in 2021 You Must Know<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This gets us to the conclusion of the information. We learned how to implement the ternary operator in Python in various methods. We&#8217;ve seen how ternary operators make code more readable and compact. I hope you understand all I&#8217;ve said thus far. If you need help with <a href=\"https:\/\/statanalytica.com\/python-programming-help\"><strong><em>python assignments<\/em><\/strong><\/a>, we have a team of experts who can help you out. Please do not hesitate to contact us.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"faqs-frequently-asked-questions\"><\/span><strong>FAQ&#8217;s (Frequently Asked Questions)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1638938332258\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><span class=\"ez-toc-section\" id=\"what-are-the-benefits-of-utilizing-pythons-ternary-operator\"><\/span><strong>What are the benefits of utilizing Python&#8217;s ternary operator?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The key advantages of the ternary operator in python are that it allows us to replace simple if statements with a single line expression, which improves code readability by lowering the number of lines.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1638938353447\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><span class=\"ez-toc-section\" id=\"in-python-how-can-we-use-the-ternary-operator\"><\/span><strong>In Python, how can we use the ternary operator?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Conditional expressions, often known as ternary operators, assess something based on whether a condition is true or false. It simply replaces the multiline if-else with a single line to test a condition, making the code more concise. <strong><em><a href=\"https:\/\/en.wikipedia.org\/wiki\/History_of_Python\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Python 2.5<\/a><\/em><\/strong> was the first version to include it.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Python is an essential programming language nowadays. Python&#8217;s popularity is increasing by the day. So there are several basic python issues where students get confused, such as tuple in Python, Python linked list, ternary operators, etc. So many students search for a solution on the internet. So in this blog, we will discuss ternary operator [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5045,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[138],"tags":[930,929,927],"class_list":["post-5044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","tag-python-ternary","tag-python-ternary-operators","tag-ternary-operator-in-python"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts\/5044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/comments?post=5044"}],"version-history":[{"count":0,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts\/5044\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/media\/5045"}],"wp:attachment":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/media?parent=5044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/categories?post=5044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/tags?post=5044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}