{"id":31960,"date":"2021-04-15T11:15:28","date_gmt":"2021-04-15T09:15:28","guid":{"rendered":"https:\/\/eiposgrados.com\/?p=31960"},"modified":"2022-08-26T14:04:20","modified_gmt":"2022-08-26T12:04:20","slug":"python-reserved-words","status":"publish","type":"post","link":"https:\/\/eiposgrados.com\/eng\/blog-python\/palabras-reservadas-python\/","title":{"rendered":"What are Keywords in Python?"},"content":{"rendered":"<p>Last week we talked to you about <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/phyton-predefined-functions\/\" class=\"rank-math-link\">Predefined functions in Python<\/a>, if you have not read it yet, we invite you to do so. Also, if you want to learn more about this fascinating language, we invite you to stop by our <a href=\"https:\/\/eiposgrados.com\/eng\/master-in-python\/\">master in Advanced Programming in Python for Big Data, Hacking and Machine Learning.&nbsp;<\/a><\/p>\n\n\n\n<p>This week we are going to teach you nothing more and nothing less than<strong> 36 keywords<\/strong> that cannot be used as names of variables, functions or any other type of identifier anymore <strong>which are reserved words.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">List of reserved words<\/h2>\n\n\n\n<p>To begin with, if we want to see the<strong> list of reserved words,<\/strong> Depending on the version of Python we use, <strong>We start by putting the help() command in the console to access the help<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"586\" height=\"138\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-9.png\" alt=\"Image\" class=\"wp-image-66973\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-9.png 586w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-9-300x71.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-9-123x29.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-9-200x47.png 200w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/figure>\n\n\n\n<p>In our case we use version 3.9. Once inside the help,<strong> We type keywords to see the list:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"886\" height=\"389\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10.png\" alt=\"Image\" class=\"wp-image-66974\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10.png 886w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10-300x132.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10-768x337.png 768w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10-123x54.png 123w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2022\/08\/image-10-200x88.png 200w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Reserved words in Python and their meaning <\/h2>\n\n\n\n<p>Next, let&#039;s quickly see what each of the <strong>reserved words <\/strong>more explicitly. <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>False <\/strong>\u2013 Boolean value, result of comparison operations or logical operations in Python<\/li><li><strong>None<\/strong> \u2013 Represents a null value<\/li><li><strong>true<\/strong> \u2013 Boolean value, same as false, result of comparison operations or logical operations in Python<\/li><li><strong>__peg_parser__ <\/strong>\u2013 Called Easter egg, related to the launch of the&nbsp;<a class=\"rank-math-link\" href=\"https:\/\/www.python.org\/dev\/peps\/pep-0617\/\" target=\"_blank\" rel=\"noopener\">new peg analyzer<\/a> It is not defined yet.<\/li><li><strong>And <\/strong>\u2013 Logical operator<\/li><li><strong>Ace <\/strong>\u2013 Used to create an alias when importing a module.<\/li><li><strong>Assert <\/strong>\u2013 Used for debugging purposes<\/li><li><strong>Async<\/strong> \u2013 Provided by the &#039;asyncio&#039; library in Python. Used to write concurrent code in Python<\/li><li><strong>Await<\/strong> \u2013 Provided by the &#039;asyncio&#039; library in Python. Used to write concurrent code in Python<\/li><li><strong>break<\/strong> \u2013 Used inside for and while loops to alter their normal behavior<\/li><li><strong>class<\/strong> \u2013 Used to define a new user-defined class<\/li><li><strong>Continue<\/strong> \u2013 Used inside for and while loops to alter their normal behavior<\/li><li><strong>Def<\/strong> \u2013 used to define a user-defined function<\/li><li><strong>Of the <\/strong>\u2013 To delete an object<\/li><li><strong>Elif <\/strong>\u2013 Used in conditional statements, equal to &#039;else&#039; and &#039;if&#039;<\/li><li><strong>Else<\/strong> \u2013 Used in conditional statements, same as &#039;elif&#039; and &#039;if&#039;<\/li><li><strong>Except <\/strong>\u2013 Used to create exceptions, what to do when an exception occurs, same as &#039;raise&#039; and &#039;try&#039;<\/li><li><strong>Finally<\/strong> \u2013 Its use ensures that the code block within it is executed even if there is an unhandled exception<\/li><li><strong>For<\/strong> \u2013 Used to make loops. We generally use it when we know the number of times we want that loop to execute<\/li><li><strong>desde<\/strong> \u2013 To import specific parts of a module<\/li><li><strong>Global <\/strong>\u2013 To declare a global variable.<\/li><li><strong>If<\/strong> \u2013 Used in conditional statements, same as &#039;else&#039; and &#039;elif&#039;<\/li><li><strong>Import <\/strong>\u2013 To import a module<\/li><li><strong>in<\/strong> \u2013 To check if a value is present in a list, tuple, etc. Returns True if the value is present, otherwise returns False<\/li><li><strong>Es <\/strong>\u2013 Used to test if the two variables refer to the same object. Returns True if the objects are identical and False otherwise<\/li><li><strong>Lambda<\/strong> \u2013 To create an anonymous function<\/li><li><strong>Nonlocal<\/strong> \u2013 To declare a non-local variable<\/li><li><strong>Not<\/strong> \u2013 Logical operator<\/li><li><strong>Or<\/strong> \u2013 Logical operator<\/li><li><strong>Pass<\/strong> \u2013 It is a null statement in Python. Nothing happens when it runs. Used as a placeholder.<\/li><li><strong>Raise <\/strong>\u2013 Used to create exceptions, what to do when an exception occurs, same as &#039;except and &#039;try&#039;<\/li><li><strong>return <\/strong>\u2013 Used inside a function to exit and return a value.&nbsp;<\/li><li><strong>try <\/strong>\u2013 Used to create exceptions, what to do when an exception occurs, same as &#039;raise&#039; and &#039;except<\/li><li><strong>While<\/strong> \u2013 Used to make loops.<\/li><li><strong>With<\/strong> \u2013 Used to simplify exception handling<\/li><li><strong>Yield<\/strong> \u2013 Used inside a function just like &#039;return&#039;, except that &#039;yield&#039; returns a generator.<\/li><\/ol>\n\n\n\n<p>Did you know all the Python Keywords or have we taught you some? <\/p>","protected":false},"excerpt":{"rendered":"<p>Do you know the reserved words in Python and their meaning? We tell you what the Keywords are and what each of them is used for. Read more!<\/p>","protected":false},"author":51,"featured_media":31962,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[407],"tags":[],"class_list":["post-31960","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-python"],"acf":[],"_links":{"self":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/31960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/comments?post=31960"}],"version-history":[{"count":0,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/31960\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media\/31962"}],"wp:attachment":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media?parent=31960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/categories?post=31960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/tags?post=31960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}