First encounter with Python

Source: Internet
Author: User

After a few days of basic learning, I gradually understand the Python language, it is a high-level language, but in the compilation of such high-level language needs to install a program called (interpreter), the role of the interpreter is specifically to the Python language automatically converted into binary machine language program.

Once installed, we do the following to test if the version of the program is available:

A command prompt will appear

Input (Python3) if shown as, then the installation is successful

Next we need to exit the current command, enter exit () and exit the current command.

We are now entering the Python program interaction environment.

Then we continue to enter Python3 at the command line, launch the Python program and enter print (' Hello World '), press ENTER

Congratulations, since then become a programmer, with our eldest words to say is (from the isolation, what beautiful ah, car ah, and you have no relationship, this life can no longer mutiny Revolution)!!

The above is in the interactive environment to write code,

    • The advantage is that you can see the result immediately by hitting a command.
    • The disadvantage is: Write the program in the above write, do not save, that is, at this moment you are in memory write program, once closed all the written program disappears.

So that some of our programs need to write to the hard disk to save, then we have to install a text editor and interpreter in one of the software, so that the side of writing a good program to save, and immediately write the results can be queried the software.

Open the software can be easily found in the area of the disk to establish a file with the subsequent storage written program, but also easy to find, at the same time we should also learn more about its shortcut, convenient for later operation, here I do not introduce.

Today, we will briefly explain the simple syntax and format of Python, when you write Python code, you need to understand the following three parts of the definition variable:

    • Variable name: The variable name is used to refer to the value of the variable. That is, whenever you want to use a variable value, you need to pass the variable name.
    • Assignment symbol: Assign value.
    • Variable value: That is, the data we store is used to record a certain state in the real world.

    • Name is the variable value that is used to apply;
    • = is the assignment value;
    • ' Lihao ' is the value, the value is the data, you can query the

If you need to take a value, you can enter print (name) on another line to find the result, and the result will show the value of name Lihao.

They are written in the value of the variable is English two days with the "" number, if the value is a number, directly fill in the numbers can be.

Second, I'll show you how they are stored, which can be directly extended to the ID

These two pictures tell us that X is consistent with the value of y query.

If I add a x=11, do I check if my value changes?

The fact that I've changed, I'm looking at x, and it's going to be the last 11. The value of the first X 10 is no longer count, but the second query of the Y value, it is still found before the value of x 10 is consistent, because the system it is read from the top down, you do not modify the value of Y, so he still applies the first value above.

So what if I want to change the value of Y to match the value of x?

We mentioned before that the program is read from the top down, so it must be added under the x=11 y=x, so that the program can understand what you mean. (Order is important)

Before that x=10 y=x, so what would happen to the command, the Python system with garbage cleaner, will automatically help you clear out the unused code, the purpose is not to account for memory.

Let me introduce you to some of Python's common syntax:

    • Del unbind

We can only find the value of x, the value of y should have been unbound, so the value of Y is not found.

    • ID Query Code ID address

The above can tell us that the ID equal value is equal, the value equal ID does not necessarily equal.

    • Type View Properties

    • = = Determines whether the value is equal
    • is to determine if ID is equal

The above is today's first encounter with Python, seemingly brief encounter. I hope you will give more support!

First encounter with Python

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.