Table of Contents
Keywords in Python programming language
Keywords are the reserved words in python
Keywords are reserved words in python. We can not use a keyword as a variable name, function name or any other identifier language.
1. and – and is a logical operator in python. Only if “and” and “if” operands are true, the result will be true. Otherwise, if one operand becomes false, the result will be false. If both operands are false, the return would be false.
The truth table of and keyword
2. as – as is used to when we want to give a module a different(user define) alias
3. assert –
4. break – break keyword is used inside of whileloop and forloop
Example for break
5. class – Python is an object-oriented programming language,
We can define our own class or user-defined class using the class keyword.
Defining a class in Python is simple. A python class can consist a lof collection of related properties or attributes and methods
Class can be defined anywhere in python. But it is a good practice to define a single class in a module.
Syntex of class in python
6. continue – continue keyword is used inside of whileloop and forloop
7. def – def is used to define a user-defined function. A function is a group of related statements for one or more specific task
8. del – del is used to delete or remove a target element in python. del is used to delete variables, list or dictionary elements.
The del statements look like this
9. elif – elif is a keyword in python similar elseif in other languages. It is used for conditional statements and test conditions. The colon(:) at the end of the statement is required.
Output
x is less than y
10. else – Elif is a keyword in python, it is used in conditional statements and test conditions. The colon(:) at the end of the statement required
Output
x is equal to y
11. except
12. finally
13. for – for is a keyword in Python, for looping statement. It is used to limit the number of times we want to execute.
Output
Hello sankar
Hello kanthan
Hello rajah
Hello yogan
Hello kumar
14. from
15. false – This keyword is used to represent a boolean false value. when become a statement is false “false” is displayed
Example 1
16. global
17. if is used in conditional statements and test conditions. The colon(:) at the end of the statement required
Output
x is greater than to y
18. import
19. in – in is used to check if the element contains a list or tuple etc….
It returns true if the value is present, it returns false if the value is not present.
another used in the forloop at python
a
p
p
y
b
i
r
t
h
d
a
y
20. is
21. lambda
22. nonlocal
23. not – not operator is used to invert the true value
24. or – or operator will turn into true if any of the operands are true
25. pass – pass is a keyword used to require implementation. pass is a null operation- noting happens when it executes.
Syntex
26. raise
27. return
28. try
29. true – This keyword is used to represent a boolean true value. When a statement is true, the word “true” is displayed.
Example
28. while – while is a keyword for looping statement. It is used to limit the number of times we want to execute
9
8
7
6
5
4
3
2
1
29. with
30. yeild
Suggested for you