Hello everyone, this is Longbow
In the last article, we explained the installation and features of python
Today we will learn the basics of python
content
First of all, we need to confirm that there is no problem with the previous installation:
Make an automatic hello applet 1 according to the input and output:
First of all, we need to confirm that there is no problem with the previous installation:
win key + r to get the following pop-up window
After confirming, you will get the following page, enter python to get its version information, and the result is that the installation is successful.
python input and output
Why put it in the beginning?
Because to use computers to help us complete our work, it is essential to realize the interaction between humans and computers. How to realize the interaction between the two? It is the input and output of data.
output:
The print() function can realize the output of strings and integer data
For example, we output, I am a longbow
We found that the English letters and Chinese characters of the string can be output normally. Unlike the output of printf() in c, you can use both single quotes and double quotes in python's print(). We can also output like this:
Support multiple string output
enter:
With the output, we can see the data, down we want the computer to see the data
An input() interface is provided in python:
name is a variable that will save the value we entered in the second line. With this variable, we can see the data by directly entering the variable name or printing.
Hands-on mini program:
Make an automatic hello applet 1 according to the input and output:
We run this program in python:
Who is the pig applet 2:
The syntax is what we have learned above, input two names, and output B is a pig.
code editor
But these small programs are composed of multiple lines of code, and we cannot directly input them line by line in python, so we need to download a text editor to edit and save the code, and the Visual Studio Code editor we used above.
Download link:
Download speed is slow
Our Download ManagerCopy Download Link
Click to create a new download
Replace before net with http://vscode.cdn.azure.cn
Compare internet speed:
run with python
We edit the code and save the code using ctrl + s in the lower left corner, then you can open python (python + file name) to run the code
This is what multiple lines of code do with the help of a text editor.
In the next preview, we will learn some common syntax and structures of python
Today's blog is here, let's try to see what fun code can be made with input and output
Looking forward to your sharing, see you next time