None in Python #
The value None, or often referred to as null value in many languages, is a special value in programming. It means there is no value, typically used when a function does not return anything or to initialize a variable without a value.
For example:
x = None
print(type(x)) # <class 'NoneType'>
print(x == True) # False
print(x == False) # False
print(x == 0) # False
print(x == "") # False
print(x == None) # True
print(x is None) # True
In the example above, we created a variable x and set its value to None. Note that the None value starts with a capitalized N. Note that None is not equal to any other value, except for None itself.
Exercise #
- Create a new variable
nameand set its value toNone.
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules