Python condition/loop supplement

Source: Internet
Author: User

Python is the language of fire in the last two years, why use it and what are the benefits of it I will not nonsense, straight cut the topic:

The unspoken rules of development are: when you learn a language and always start with "Hello World", I write a Hello world

C:\windows\system32>pythonpython 3.6.2 (v3.6.2:5fd33b5, Jul  8, 04:57:36) [MSC v.1900-bit (AMD64)] on win32t Ype "Help", "copyright", "credits" or "license" for more information.>>> print ("Hello World") Hello World>> >

You can see that it outputs the content, is it simple? You know why you use Python?

Next say "Print ()", in Python3 inside "print" has become a function, function parentheses to run, you inside the content is the function parameter

Let's talk about it. Input: "Input ()"

>>> a=input ("Input content:") input content:hello>>>

Then variables, changes in the amount of change = = change, Volume = = metering/saving state, is plainly, you open a variable, the interpreter will open a memory in your memory space (the value of the variable, and then give it a name), later in the function of this piece of deep experience, now do not need to know, such as:

A = 1a = "Chen" a = ..... These are variables, simple points, see the following formula: variable name = variable Value

Why there is it, because it is a save your current state, different state will produce different results, such as you in the football lottery, and then happy to go to the clubhouse, and then halfway was robbed, you went to the sea, which reflects your state has changed. , all data in Python is built around the concept of objects that contain some basic data types: numbers, strings, lists, tuples, dictionaries, etc. (see chapter II), where all the data stored in the program is an object

An object (such as A=1) has: an    identity (ID) one value (Type    ) (    viewed by variable name a)

Assigning values to variables

The difference from the C language is that the variable assignment operation has no return value chain assignment: Y=x=a=1 multivariate assignment: x,y=1,2 x,y=y,x increment Assignment: x+=1

Variable and not variable

When an instance is created, the identity and type are immutable, and if the value is not modifiable, the immutable object is mutable if the value can be modified

The latter (data type) will talk about what is mutable and what is immutable.

Comparison

Identity comparison, type comparison, value comparison x=1y=1x is Y #x与y是同一个对象, is a comparison of ID, that is, identity type (x) is type (y) #对象的类型本身也是一个对象, so you can compare two objects of type identity x = = y #== Compares the values of two objects for equality

Container: An object that contains a reference to another object, called a container or collection

Cycle judgment can go to the article to find ...

Python condition/loop supplement

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.