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

Day None Datatype & input() function in Python

Linda Hamilton
Release: 2024-11-19 19:59:02
Original
1037 people have browsed it

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()
Copy after login

Output:

hello
Copy after login

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())
Copy after login

Output:

hello
None
Copy after login

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())

Copy after login

Output:

hello
30
Copy after login

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

Copy after login

Output:

Enter your name: Pritha
Welcome to Python Pritha
<class 'str'>


Copy after login

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!

source:dev.to
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template