Python from novice to great god (3)-input and output

Starting today, my python original free course has been updated, striving to be easy to understand and explain in simple terms. If you are willing to save five minutes of vibrato every day, follow this series of courses to learn, I believe that when you continue to learn, you will be very Thank you for the original decision.

                                                                                       WeChat public account

  I am a computer graduate student at Ocean University of China, mainly researching deep learning, computer vision and python. I look forward to your attention and work together!

Today we are going to talk about the input and output of python. It is easy to understand that the so-called input is to input data through the keyboard; the so-called output is to output data through python.

The most important thing to learn a programming language is to practice. I hope you can open the editor and practice with me. If you don't have python installed, just download and install it by following the installation tutorial on Du Niang.

Python basics

1. Output

Let's talk about output first, because the output is very simple, only one line of code, as shown in the figure:

The output is very simple, you only need to use one function: print() , but there are several points worthy of attention:

1. If you want to output letters or Chinese characters, you need to add double quotes in the print() function, as shown in the figure above.

2. If you want to output a number from 0 to 9, you do not need to add double quotes in the print() function, as shown in the following figure:

Two, input

The input statement is assigned to a variable through an input() function. It may be more convoluted to say this, and you can quickly understand it through the code.

enter

The code in the above figure means to get the value we input from the keyboard through an input() function. As shown in the above figure, I input 123. After the input() function gets 123 input from the keyboard, I pass 123 to the a variable. In this way we have completed an input.

The above is the content learned today. Is it very simple? You must practice it yourself. If you have any questions, see you in the comment section.

Guess you like

Origin blog.csdn.net/qq_38230338/article/details/107755590