The input () function in Python
Python's built-in input () function allows users to enter data, convert it into a string, and return the entered content.
Input function syntax ()
input([prompt])
Parameter of input function ()
input () has a unique parameter:
prompt
: is a string entered by the user.
For example
1. Input () method works in Python
# nhận input từ người dùng inputChuoi = input() print('Chuỗi đầu vào là:', inputChuoi)
Suppose the input user input is "Website TipsMake.com". Run the program, the result is:
Website TipsMake.com Chuỗi đầu vào là: Website TipsMake.com
2. Receive input from user with prompt before entering.
# nhận input từ người dùng inputChuoi = input('Nhập chuỗi:') print('Chuỗi đầu vào là:', inputChuoi)
Result:
Nhập chuỗi: Website TipsMake.com Chuỗi đầu vào là: Website TipsMake.com
See also: Built-in Python functions
4.3 ★ | 3 Vote
You should read it
May be interested
- Hex () function in Pythonthe hex () function is one of python's built-in functions, used to convert an integer into the corresponding hexadecimal form.
- The map () function in Pythoncontinuing with the topic of built-in functions in python, the article will introduce you to the map () function with syntax, usage as well as specific examples. invites you to read the track.
- The function dir () in Pythonthe dir () function in python returns a list of valid properties of the object. quantrimang will learn more about this function content through the article. invites you to read the track.
- The function set () in Pythonin this article, tipsmake.com will learn with you about set (), syntax, parameters and specific examples. invites you to read the track.
- Help () function in Pythonthe built-in help () function in python is used to display documents and invoke the help system of modules, functions, classes, keywords ...
- Sum () function in Pythonthe built-in function sum () in python returns the sum of all numbers in iterable.
- The slice () function in Pythonthe slice () function in python returns a slice object that helps you determine how to cut an existing string.
- The chr () function in Pythonin python, the chr () function returns a character (a string) from an integer that represents the unicode of the returned character.
- The iter () function in Pythoncontinuing with the topic of python's built-in functions, the article will introduce you to the iter () function with the syntax, usage as well as specific examples. invites you to read the track.
- The pow () function in Pythonthe pow () function built into python returns the value of x with the power of y (xy). if there is a third parameter, the function returns x to the power y, the module z.