+ INFORMATION

Share on social networks!

What are Keywords in Python?

Last week we talked to you about Predefined functions in Python, 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 master in Advanced Programming in Python for Big Data, Hacking and Machine Learning. 

This week we are going to teach you nothing more and nothing less than 36 keywords that cannot be used as names of variables, functions or any other type of identifier anymore which are reserved words.

List of reserved words

To begin with, if we want to see the list of reserved words, Depending on the version of Python we use, We start by putting the help() command in the console to access the help:

Image

In our case we use version 3.9. Once inside the help, We type keywords to see the list:

Image

Reserved words in Python and their meaning

Next, let's quickly see what each of the reserved words more explicitly.

  1. False – Boolean value, result of comparison operations or logical operations in Python
  2. None – Represents a null value
  3. true – Boolean value, same as false, result of comparison operations or logical operations in Python
  4. __peg_parser__ – Called Easter egg, related to the launch of the new peg analyzer It is not defined yet.
  5. And – Logical operator
  6. Ace – Used to create an alias when importing a module.
  7. Assert – Used for debugging purposes
  8. Async – Provided by the 'asyncio' library in Python. Used to write concurrent code in Python
  9. Await – Provided by the 'asyncio' library in Python. Used to write concurrent code in Python
  10. break – Used inside for and while loops to alter their normal behavior
  11. class – Used to define a new user-defined class
  12. Continue – Used inside for and while loops to alter their normal behavior
  13. Def – used to define a user-defined function
  14. Of the – To delete an object
  15. Elif – Used in conditional statements, equal to 'else' and 'if'
  16. Else – Used in conditional statements, same as 'elif' and 'if'
  17. Except – Used to create exceptions, what to do when an exception occurs, same as 'raise' and 'try'
  18. Finally – Its use ensures that the code block within it is executed even if there is an unhandled exception
  19. For – Used to make loops. We generally use it when we know the number of times we want that loop to execute
  20. desde – To import specific parts of a module
  21. Global – To declare a global variable.
  22. If – Used in conditional statements, same as 'else' and 'elif'
  23. Import – To import a module
  24. in – To check if a value is present in a list, tuple, etc. Returns True if the value is present, otherwise returns False
  25. Es – Used to test if the two variables refer to the same object. Returns True if the objects are identical and False otherwise
  26. Lambda – To create an anonymous function
  27. Nonlocal – To declare a non-local variable
  28. Not – Logical operator
  29. Or – Logical operator
  30. Pass – It is a null statement in Python. Nothing happens when it runs. Used as a placeholder.
  31. Raise – Used to create exceptions, what to do when an exception occurs, same as 'except and 'try'
  32. return – Used inside a function to exit and return a value. 
  33. try – Used to create exceptions, what to do when an exception occurs, same as 'raise' and 'except
  34. While – Used to make loops.
  35. With – Used to simplify exception handling
  36. Yield – Used inside a function just like 'return', except that 'yield' returns a generator.

Did you know all the Python Keywords or have we taught you some?

Subscribe to our newsletter to stay up to date with all the news

EIP International Business School informs you that the data in this form will be processed by Mainjobs Internacional Educativa y Tecnológica, SA as the person responsible for this website. The purpose of collecting and processing personal data is to respond to the query made as well as to send information about the services of the data controller. Legitimation is the consent of the interested party.
You can exercise your rights of access, rectification, limitation and deletion of data in compliance@grupomainjobs.com as well as the right to file a claim with the supervisory authority. You can consult additional and detailed information on Data Protection in the Privacy Policy that you will find in our Web page
marter-in-python

1 thought on “¿Qué son los Keywords en Python?”

Leave a comment