What are the inputs and outputs in Python? (example)

Source: Internet
Author: User
For the first time a friend of the Python programming language, just beginning to learn Python programming for input and output in PythonThis aspect of the understanding is relatively small, in this article we will come to understand python input and outputRelated knowledge.

Output

You can output the specified text to the screen by using print () to enclose the string in parentheses. For example, the output of ' Hello, world ', implemented in code as follows:

>>> print (' Hello, World ')

The print () function can also accept multiple strings, separated by a comma "," to connect to a string of outputs:

>>> print (' The quick brown fox ', ' Jumps over ', ' the Lazy Dog ') The "quick brown fox jumps over the" the Lazy Dog

Print () prints each string sequentially, encounters a comma "," and outputs a space, so the output string is spelled like this:

Print () also prints integers, or calculates the result:

>>> print (300>>>) print (100 + 200) 300

Input

Now you can use print () to output the results you want. But what if you want users to enter some characters from the computer? Python provides an input () that allows the user to enter a string and store it in a variable. For example, enter the user's name:

>>> name = input () Michael

When you enter name = input () and press ENTER, the python interactive command line is waiting for your input. At this point, you can enter any character and then press ENTER to complete the input.

Once the input is complete, there is no hint, and the Python interactive command line is back to >>>. So where is the content we just entered? The answer is stored in the name variable. You can enter name directly to view variable contents:

>>> name ' Michael

In short, any computer program is to perform a specific task, with the input, the user can tell the computer program required information, with the output, the program can be run to tell the user the results of the task.

Inputs are input and outputs are output, so we refer to the input and output collectively as input/output, or abbreviated to IO.

Input () and print () are the most basic inputs and outputs below the command line, but the user can also complete the input and output through other more advanced graphical interfaces, such as entering their name in a text box on a webpage, and clicking "OK" to see the output on the page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.