None Datatype:
The Python NoneType is a data type that represents the absence of a value. In Python, the NoneType is represented by the keyword "None".
Example:
In this example When you run the code, it will display "hello".
def display():
print("hello")
display()
Output:
hello
Example 2:
The None is printed because that's the default return value of a function that doesn't have an explicit return statement.
def display():
print("hello")
print(display())
Output:
hello
None
Example 3:
"hello" is printed by the print() inside the function.
30 is printed by the print() outside the function, which displays the value returned by display().
def display():
print("hello")
return 10+20
print(display())
Output:
hello
30
input() function:
The builtin function input() in Python takes input from a user and returns it as a string by default.
Example:
name = input("Enter your name: ")
print("Welcome to Python", name)
print(type(name))
Output:
Enter your name: Pritha
Welcome to Python Pritha
<class 'str'>
Top comments (1)
data type of input() is a string
Some comments have been hidden by the post's author - find out more