Python 1 Basic Concepts

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/known/archive/2010/07/31/1789290.html

1. Constants

Python constants have no Name

2. Number

There are 4 classes of Python:

* Integer: 2

* Long integers: 655535 and other large integers

* Floating point number: 1.2, 1.2e-3, E is a power of 10,

* Plural ( -5+4j)

3. String

Python does not have char type, single, double quote "", ' is a meaning

* Single quote: ' Quote me on this '

* Double quotes: "Waht's Your Name"

* Three quotes: ' This is the first line.

The second line.

Or

"What ' s your name?"

My name is known. "" "

* Escape character: ' what\ ' s your name? '

* Natural string: Start with R or R, r "Hello world!\n"

4. Variables

Name rule:

* The first character is a letter (uppercase or lowercase) or an underscore (_)

* Other part characters are letters (uppercase and lowercase), numbers, underscores

* Case-sensitive, myname and myname are two different variables

5. Data type

Python basically has no data type, which is the number and string, and the advanced type is the class

6. Objects

Python sees everything as an object, and it counts 2 as an object.

7. Logical lines and physical lines

The physical line is what you see in the editor. The logical line is what Python can recognize. In general, Python considers a physical line to correspond to a logical line.

If you want to use more than one logical line in a physical row, split it with a semicolon (;), which indicates the end of a logical line or statement. We recommend that you do not write this and that the readability is poor.

Example: i = 5;print (i)

Equivalent

i = 5

Print (i)

If you want to write a logical line in multiple physical rows, you use a backslash (\) to connect.

Example: s = "This is A\

String

Equivalent

s = "This is a string"

8 Indent

Indentation in Python is a test of importance. The gap at the beginning of the line is important, examples:

Print ("Hello")

Print ("World")

The second print statement will have an error because it has a blank space in front of it.

The statement of the consent level must have the same indentation.

Do not mix whitespace and tabs so that it will not work on different platforms.

It is strongly recommended that you use a single tab or two or four spaces when indenting. I suggest to use four spaces as always

9 operator

10 expressions

Python 1 Basic Concepts

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.