Anyone Can Code.
What are keywords? Well simply put, keywords are certain words/commands in Python (or any programming language) that have a predefined meaning and cannot be used for anything, except for the predefined purpose.
Let's look at an example of what happens when we use a keyword for something other than its predefined purpose.
and = 2
File "<string>", line 1 and = 2 ^ SyntaxError: invalid syntax
Here, we see that we get a SyntaxError
which means that something is wrong with the
way we have written our code. If you don't already know, and
is a keyword (a logical operator to be precise) and it's use in Python is to check whether
quantities both hold true or false, we will be covering this in our
Logical Operators Tutorial, so don't worry about it for now.
So how many keywords do we have in Python? There are exactly 33 keywords in Python. all of them are lowercase except for True, False and None. As you progress through this course you will start to see where these keywords are used.
Given below is a table with all of the 33 keywords, listed alphabetically. Give it a brief read, there's no need to memorize it. Once you start programming in Python, you will see that it will come to mind automatically.
and | as | assert | break |
class | continue | def | del |
elif | else | except | False |
finally | for | from | global |
if | import | in | is |
lambda | None | nonlocal | not |
or | pass | raise | return |
True | try | while | with |
yield |
Now that you have seen these keywords, keep them in mind. Your IDE (Integrated Development Environment) should highlight these words when you type them, so if you ever use one by mistake for the wrong purpose, you will know that you have made an error. Besides, the Python interpreter will tell you if you make an error, and where!
That's it for this tutorial! Click Next to access the next tutorial!
This site uses cookies to improve your experience as well as for site metrics. To see more, check out our Privacy Policy