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:

  1. 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

May be interested

  • Hex () function in PythonHex () function in Python
    the hex () function is one of python's built-in functions, used to convert an integer into the corresponding hexadecimal form.
  • The map () function in PythonThe map () function in Python
    continuing 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 function dir () in Python
    the 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 PythonThe function set () in Python
    in this article, tipsmake.com will learn with you about set (), syntax, parameters and specific examples. invites you to read the track.
  • Help () function in PythonHelp () function in Python
    the built-in help () function in python is used to display documents and invoke the help system of modules, functions, classes, keywords ...
  • Sum () function in PythonSum () function in Python
    the built-in function sum () in python returns the sum of all numbers in iterable.
  • The slice () function in PythonThe slice () function in Python
    the slice () function in python returns a slice object that helps you determine how to cut an existing string.
  • The chr () function in PythonThe chr () function in Python
    in python, the chr () function returns a character (a string) from an integer that represents the unicode of the returned character.
  • The iter () function in PythonThe iter () function in Python
    continuing 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 in Python
    the 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.