Keyword-in-Python
Keyword-in-Python
Topperworld.in
Keywords
• Python keywords are unique words reserved with defined meanings and
functions that we can only apply for those functions. You'll never need to
import any keyword into your program because they're permanently
present.
• Python's built-in methods and classes are not the same as the keywords.
Built-in methods and classes are constantly present; however, they are not
as limited in their application as keywords.
• Assigning a particular meaning to Python keywords means you can't use
them for other purposes in our code. You'll get a message of SyntaxError if
you attempt to do the same. If you attempt to assign anything to a built-in
method or type, you will not receive a SyntaxError message; however, it is
still not a smart idea.
©Topperworld
Python Programming
1. print( 4 == 4 )
2. print( 6 > 9 )
3. print( True or False )
Output:
True
False
True
©Topperworld
Python Programming
OR, ∨ || or
NOT, ¬ ! not
CONTAINS, ∈ in
IDENTITY === is
Example:
x = 10
y=3
addition = x + y
comparison = x > y
logical_and = x > 5 and y < 5
assignment = x += y
print("Addition:", addition)
print("Comparison:", comparison)
print("Logical AND:", logical_and)
print("Assignment:", assignment)
©Topperworld
Python Programming
Output:
Addition: 13
Comparison: True
Logical AND: False
SyntaxError: cannot use assignment expressions with subscript
Examples:
©Topperworld
Python Programming
Output:
1
2
3
0
1
2
Examples:
if number > 0:
print("The number is positive.")
Output:
©Topperworld
Python Programming
©Topperworld