Day01-python Foundation

Source: Internet
Author: User

One, the basics of programming

1, what is programming?

The programmer writes his own thought process according to the needs of a grammar style that becomes a language, and the result of the output is a file containing a bunch of characters. This pile of files is a bunch of characters when it's not running. Only in a particular environment can it be called a programming file after it is run by the compiler.

2, what is a programming language?

The expression that can be recognized by the computer is the programming language. Language is the medium of communication, and programming language is the medium that the programmer communicates with the computer.

3. What are the categories of programming languages? --angle, introduction, relative three dimensions

Assembly language: Computer angle, binary execution, 0 and 1, high learning cost, fast execution speed.

Machine language: Computer angle, abbreviated English identifier instead of binary, the learning cost is relatively high, the execution speed is relatively fast.

Advanced Language: Programmer's point of view, the learning cost is relatively low, the execution speed is relatively slow.

Compiled: code needs two compile, compiled into binary, overall execution, debugging trouble. such as c,c# language.

Explanatory: Code does not need two compilation, according to the interpreter, line by row, debugging simple. such as Python,shell language.

Two, the first Pyhon code

Print (' Hello,world ')

Three, variable

1, what is the definition of a variable?

Variable: The amount of change. There are no immutable units in the computer. such as: "Plants vs. Zombies" in the progression of the blame, etc., are expressed by the value of change.

The variable is represented in Python: user_name = ' None ', that is: variable name = variable Value

Python represents constants: User_name = ' None ', note: Uppercase variable names are just behavioral habits between programmers, not behavior constraints. Python does not constrain constants.

2, what is the definition specification for variables?

1, composed of numbers, letters, underscores.

2, cannot start with a number.

3, the variable name is understood by others to understand as the basis < interpretation of the clear; use underscores to correlate with each other. such as User_name

4, the variable name cannot use the keyword.

5, variable names are case-sensitive.

6, the variable name is best not to use Chinese.

Four, note

Single-line Comment: #

Multiline Comment: "" "... """

Five, data type

1, String, note: single quotes, double quotes, and three quotation marks do not differ. It is mainly in the combination of single and double quotation marks.

Username = str (' None ')

2, Digital

age = Int (18)

3, floating-point type

Age=float (18.1)

3, Boolean value

False or True

4, List:

list = [' None ', ' malse ', 18]

Print List[0]

The subscript for the list starts at 0

5, Dictionary:

List = {' name ': ' None ', ' hex ': ' Malse ', ' Age ': 18}

Print list[' name ']

Dictionaries are stored in key-values, and are unordered. The value is also used when key-values values are taken.

Six, formatted output

Print (' My name is%s,mysql-age is%d% (' none ', ' 18 ')

%s: Character placeholder, also available for numbers.

%d: Numeric placeholder, not available for characters.

Seven, basic operator:

Arithmetic operations:

+: Add

-: Subtract

*: Multiply

/: Divide

%: Take the remainder

* *: Power-party

: dividing, taking integers

Comparison operation:

= =: equals

! =: Not equal to

: Greater Than

<: Less than

>=: greater than or equal to

<=: Less than or equal to

Assignment operation:

=: Simple Assignment

+ =: Addition Assignment

-=: Subtraction Assignment

*=: Multiplication Assignment

/=: Division Assignment

%=: The value of the remainder assignment

=: Power Assignment

=: Take integer assignment

Logical operation:

And: Logical AND, two are true, then true

Or: Logical OR, one is true, then true

Not: Logical not, true false, False is true.

Eight, conditional judgment

1,if conditions

If condition:

。。。

Elif

。。。

Else

。。。

Nine, Loop

1,while Cycle

While True:

。。。

Contiune: Jump out of this cycle, that is, after this cycle is not executed

Break: Jumps out of all loops, that is, all loops are not executed.

Day01-python Foundation

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.