Introduction:
Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive.
In this article you will get a detailed view about this keywords.
1. True : This keyword is used to represent a boolean true. If a statement is true, “True” gets printed.
2. False : This keyword is used to represent a boolean false. If a statement is false, “False” gets printed.
True and False in python are same as 1 and 0. Example is given below :
Next article- Python keywords Part-2
Python keywords Part-1, where you will have a clear knowledge about the keywords of python
#python training
#python data analysis
#best python tutorial
#python classes near me
#learn python for beginners
#python online training
#django course
#advanced python course
#python course fees
#introduction to data science in python
#free python tutorial
#learn python basics
#python study
#python and ai
#python computer science
#learn python step by step
#best course to learn python
#learn python with projects
#python artificial intelligence tutorial
In this article you will get a detailed view about this keywords.
1. True : This keyword is used to represent a boolean true. If a statement is true, “True” gets printed.
2. False : This keyword is used to represent a boolean false. If a statement is false, “False” gets printed.
True and False in python are same as 1 and 0. Example is given below :
print
False
=
=
0
print
True
=
=
1
print
True
+
True
+
True
print
True
+
False
+
False
3. None : The None keyword is used to define a null variable or an object. In Python, None keyword is an object, and it is a data type of the class NoneType . We can assign None to any variable, but you can not create other NoneType objects. Note: All variables that are assigned None point to the same object.
It is an object of its own datatype – NoneType. It is not possible to create multiple None objects and can assign it to variables.
4. and : This a logical operator in python. “and” Return the first false value .if not found return last. The truth table for “and” is depicted below.
Truth table for A and B
Following lines are straight from the python docs explaining this:
The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned.
The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned.
Note that neither and nor or restrict the value and type they return to False and True, but rather return the last evaluated argument. This is sometimes useful, e.g., if s is a string that should be replaced by a default value if it is empty, the expression s or ‘foo’ yields the desired value. Because not has to create a new value, it returns a boolean value regardless of the type of its argument (for example, not ‘foo’ produces False rather than ”.)
5. or : This a logical operator in python. “or” Return the first True value.if not found return last.The truth table for “or” is depicted below.
Truth table for A or B
6. not : This logical operator inverts the truth value. The truth table for “not” is depicted
below.
Truth table for not
output :
7. assert : This function is used for debugging purposes. Usually used to check correctness of code. If a statement evaluated to true, nothing happens, but when it is false, “AssertionError” is raised. One can also print a message with the error, separated by a comma.
8. break : “break” is used to control the flow of loop. The statement is used to break
out of loop and passes the control to the statement following immediately after loop.
9. continue : “continue” is also used to control the flow of code. The keyword skips the current iteration of the loop, but does not end the loop.Illustrations of break and continue keywords can be seen in the article below.
10. class : This keyword is used to declare user defined classes.
11. def : This keyword is used to declare user defined functions.
12. if : It is a control statement for decision making. Truth expression forces control to go in “if” statement block.
13. else : It is a control statement for decision making. False expression forces control to go in “else” statement block.
14. elif : It is a control statement for decision making. It is short for “else if” if, else and elif conditional statements are explained in detail here article.
15. del : del is used to delete a reference to an object. Any variable or list value can be deleted using del.
output :
Runtime Error :
Next article- Python keywords Part-2
Python keywords Part-1, where you will have a clear knowledge about the keywords of python
if you want to learn python for free, here are the top 5 courses available who provide you free python courses
1. Codeacademy: If you like interactive learning, then there is no better place than Codecademy. click here to visit
2. Udemy: like Udemy because you can virtually find a course on anything you want to learn and that too for free. click here to visit
3.Google's python class: Google has its own excellent set of Python tutorials for beginners, known as Google's Python class. This is a free class for people with a little bit of programming experience and who want to learn Python. click here to visit
4.Microsoft's free python course: Like Google , Microsoft also has its own class for Python
click here to visit
5. Coursera: This is the platform from where you can learn python from scrap to advance with the top leading universities. click here to visit
1. Codeacademy: If you like interactive learning, then there is no better place than Codecademy. click here to visit
2. Udemy: like Udemy because you can virtually find a course on anything you want to learn and that too for free. click here to visit
3.Google's python class: Google has its own excellent set of Python tutorials for beginners, known as Google's Python class. This is a free class for people with a little bit of programming experience and who want to learn Python. click here to visit
4.Microsoft's free python course: Like Google , Microsoft also has its own class for Python
click here to visit
5. Coursera: This is the platform from where you can learn python from scrap to advance with the top leading universities. click here to visit
#python training
#python data analysis
#best python tutorial
#python classes near me
#learn python for beginners
#python online training
#django course
#advanced python course
#python course fees
#introduction to data science in python
#free python tutorial
#learn python basics
#python study
#python and ai
#python computer science
#learn python step by step
#best course to learn python
#learn python with projects
#python artificial intelligence tutorial
#micropython
#python for data science
#data science from scratch
#micropython esp32
#machine learning using python
#matplotlib
#python 3
#scikit learn
#tkinter
#earn python the hard way
#python for data analysis
#python ai
#fluent python
#introduction to machine learning with python
#python machine learning
#deep learning with python
#best way to learn python
0 Comments
If you have any doubt, Please let me know.