Home >Backend Development >Python Tutorial >Day None Datatype & input() function in Python

Day None Datatype & input() function in Python

Linda Hamilton
Linda HamiltonOriginal
2024-11-19 19:59:021039browse

Day  None Datatype & input() function in Python

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 the function is called , so inside the function will be printed.

def display():
    print("hello")
display()

Output:

hello

Example 2:

In this example the function is does not return any value. so the print(display()) is become 'None'.

def display():
    print("hello")
print(display())

Output:

hello
None

Example 3:

In this example the return statement will be used to return the value(i.e 30). If we not use any return statement the output will be 'None'.

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'>


The above is the detailed content of Day None Datatype & input() function in Python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn