Table of content

None Datatype in Python

None: None means nothing, not any value.

Ex: not at all, not a bit, etc..

The None Datatype is used to define the null value or no value, the none value means not 0, or False value, and it is a data it's own.

Example:

Assume a=10, that means a is the reference variable pointing to 10 and if I take a=none then a is not looking to the object 10

I have one function called def f1(); if I call this function then it is going to return the value ten and if I am going to assign this value to the x, x=f1() and print(x) is going to print the value 10

def f1()
return 10
x=f1()
print(x)= ?

calling-fun-with-retrning-value

output-of-calling-fun

In the same way, I am calling a function def f1() and to print("hello") and assigning this to x, x=f1() then this function is not going to return anything, hence to handle this kind of situation where the function is not going to return anything then we are using the none datatype to handle

def f1()
print("Hello")
x=f1()
print(x)

execting-none-programm

None is also internally represented as an object, consider a=none, that means a is officially not pointing to any value; instead, it is pointing to none.

If it is an object if you can type as a print(id(a)) you will get an address and to know the type of this if you print(type(a)) then it will reply as none.

a=None
print(id(a))
print(type(a))

none-type

Inside the python, there will be only one None object can be created, if you assign
None to any number of variables also, all the variables are going to represent the same object

a=None
b=None
c=None
def f1():
  pass
d=f1()
print(id(a),id(b),id(c),id(d))

only-one-none-object

out-put-of-none-object

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions