This lesson will teach you about identifiers (names given to variables, functions, etc.) and Python’s keywords and Terms, with examples to better understand the topics.
In Python, reserved words are referred to as keywords. The structure and syntax of the Python language are described using them. You can’t use a keyword to recognize anything, including variables, functions, or other types of code.
In Python, Keywords are case-sensitive. There are 33 keywords in Python; this figure can change slightly over time. Except for True, False, and None, all keywords are lowercase and must be written that way. Below is a list of all Python keywords.
False | Await | else | Import | pass |
---|---|---|---|---|
None | break | except | In | raise |
True | Class | finally | Is | return |
And | continue | for | Lambda | try |
As | Def | from | Nonlocal | while |
Assert | Del | global | Not | with |
Async | Elif | If | Or | yield |
Example
False, True
Python has two truth values: True and False. They are the outcomes of Python’s logical (Boolean) or comparison operations. For instance:
>> 100 == 100 True >>> 98 > 3 True >>> True or False True >>> 10 <= 8 False >>> 379 > 700 False >>> True and False False
Since the first three statements in this example are true, the interpreter returns “True” while returning False for the other three statements. Python treats True and False as equivalent to 1 and 0. The following illustration can support this:
>> True == 1 True >>> False == 0 True >>> True + True 2
A name provided to an entity, such as a class, function, variable, etc., is called an identifier. Python identifies a variable, function, class, module, or other objects by a name or identifier.
Python is a computer language that recognizes cases. The naming guidelines for Python identifiers are as follows:
mySubject
, var 1
, and is_Valid_Name
.1variable
is not.Example: global = 1
a@ = 0
i = 10
is a valid name, count = 10
would make more sense and simplify understanding what it stands for when you next review your code.Subject_Name_is_Math
.This concludes the Python Keywords and Identifiers lesson. In the next lesson, you will learn different comment types in Python and their usage.