Generally, every programming language has syntax like the same python has its own syntax, key words, literals and identifiers.
In the previous posting we learn how to execute single commands and multiple commands in shell. Now we focused on keywords in python.
As we know a keyword is a reserve word which has a meaning and specific functionality in the programming language. These keywords should not used as a constants or variable in the programming.
Below is the list of python keywords.
Sno | Keyword | Usage |
---|---|---|
1 | and | A logical operator |
2 | as | To create an alias |
3 | assert | For debugging |
4 | break | To break out of a loop |
5 | class | To define a class |
6 | continue | To continue to the next iteration of a loop |
7 | def | To define a function |
8 | del | To delete an object |
9 | elif | Used in conditional statements, same as else if |
10 | else | Used in conditional statements |
11 | except | Used with exceptions, what to do when an exception occurs |
12 | FALSE | Boolean value, result of comparison operations |
13 | finally | Used with exceptions, a block of code that will be executed no matter if there is an exception or not |
14 | for | To create a for loop |
15 | from | To import specific parts of a module |
16 | global | To declare a global variable |
17 | if | To make a conditional statement |
18 | import | To import a module |
19 | in | To check if a value is present in a list, tuple, etc. |
20 | is | To test if two variables are equal |
21 | lambda | To create an anonymous function |
22 | None | Represents a null value |
23 | nonlocal | To declare a non-local variable |
24 | not | A logical operator |
25 | or | A logical operator |
26 | pass | A null statement, a statement that will do nothing |
27 | raise | To raise an exception |
28 | return | To exit a function and return a value |
29 | TRUE | Boolean value, result of comparison operations |
30 | try | To make a try…except statement |
31 | while | To create a while loop |
32 | with | Used to simplify exception handling |
33 | yield | To end a function, returns a generator |
Remember All the Python keywords contain lowercase letters only.