{"id":23,"date":"2024-01-24T12:59:09","date_gmt":"2024-01-24T12:59:09","guid":{"rendered":"https:\/\/learnpython.elegantwallp.com\/?p=23"},"modified":"2024-01-24T12:59:10","modified_gmt":"2024-01-24T12:59:10","slug":"python-constants","status":"publish","type":"post","link":"https:\/\/learnpython.elegantwallp.com\/2024\/01\/24\/python-constants\/","title":{"rendered":"Python Constants"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you\u2019ll learn how to define Python constants.<\/p>\n\n\n\n<p>Sometimes, you may want to store values in\u00a0variables. But you don\u2019t want to change these values throughout the execution of the program.<\/p>\n\n\n\n<p>To do it in other programming languages, you can use constants. The constants are like variables but their values don\u2019t change during the program execution.<\/p>\n\n\n\n<p>The bad news is that Python doesn\u2019t support constants.<\/p>\n\n\n\n<p>To work around this, you use all capital letters to name a variable to indicate that the variable should be treated as a constant. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>FILE_SIZE_LIMIT = 2000<\/code><small>Code language: Python (python)<\/small><\/code><\/pre>\n\n\n\n<p>When encountering variables like these, you should not change their values. These variables are constant by convention, not by rules.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you\u2019ll learn how to define Python constants. Sometimes, you may want to store values in\u00a0variables. But you don\u2019t want to change these values throughout the execution of the program. To do it in other programming languages, you can use constants. The constants are like variables but their values don\u2019t change during [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-1-fundamentals"],"_links":{"self":[{"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":1,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":24,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/posts\/23\/revisions\/24"}],"wp:attachment":[{"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnpython.elegantwallp.com\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}