This article introduces the input and output of Python. Since it is Python code, then there must be output, then, PythonHow does output ?
Output
Use print() to add a string in brackets to Output specified text. For example, to output 'hello, world', the code is as follows:
>>> print('hello, world')
print() The function can also accept multiple strings, separated by commas "," If you turn it on, you can connect it into a string and output :
>>> print('The quick brown fox', 'jumps over', 'the lazy dog') The quick brown fox jumps over the lazy dog
print() will print each string in turn, and when it encounters a comma "," it will be output A space, therefore, The output string of is spelled like this:
print() can also be Print integers, or calculation results:
>>> print(300) 300 >>> print(100 + 200) 300
Having said so much output, so what is Python's input?
Input
Now, you can use print() to output the results you want. However, what if you want the user to enter some characters from the computer? Python provides an input() that allows users to enter a string and store it in a variable. For example, enter the user's name:
>>> name = input() Michael
name = input() and press Enter, the Python interactive command line is waiting for your input. At this time, you can enter any characters and press Enter to complete the input.
After the input is completed, there will be no prompts, andPythonthe interactive command line returns to the >>> state. So where did the content we just entered go? The answer is stored in the name variable. You can directly enter name to view the variable content:
>>> name 'Michael'
about the input and output of Python
The above is the detailed content of Understand the input and output of Python in one article. For more information, please follow other related articles on the PHP Chinese website!