First, machine language (interpreted language and compiled language) introduction
1, compiled language: the compiled language is to write good programming compiled into machine language and then execute, before running a one-time compilation, such as C, C + +.
Advantages: Fast running speed, disadvantage: Long compilation time
2. Interpreted language: Compile at run time, execute one line of compilation, like Python, Ruby, PHP, Java, etc.
Advantages: Short compile time, when to compile with; disadvantage: slow speed
Ii. introduction of Python
Python is an object-oriented, interpretive language that is easy to learn, with the largest number of third-party libraries in a language
Python's usefulness: background development, automated operations, crawlers, artificial intelligence, data analysis, automated testing, embedded development, desktop software, etc.
Third, Python installation
Iv. variables and grammatical basis
1, variables are used to store things, for the use of later programs, Python variables are defined by the equals sign
2, the definition of the string to be quoted: single and double quotation marks alone, no difference, 1) The definition of the value of single quotation marks the outermost to use double quotation marks; words= "Let's Go"
2) The value of the definition has double quotation marks, the outermost is the single quotation mark; words= ' Test industry ' it's hard "ah '; 3) defined values are both single quotes and double quotes, the outermost with three single quotes ' Let's go ' really hard ' ah '
3, the definition number does not need to quote 4, note: 1) Single-line comment with #;2) multiline comment with three single quotation marks ""; 3) Quick Comment shortcut, select the line to comment, shortcut ctrl+/5, equal sign, an equal sign is an assignment meaning, two equals equals meaning 7, link multiple strings with and 8, use input to receive the value is the string 9, look at the type of a variable (variable name) 10, variable conversion, the variable score string type into the int type, Score=int (score) 11, Count =count+1 equals count+ = 15, conditional judgment 1, Python use if else to make conditional judgments. such as: 2, multi-branch use if elif....else, such as:
Six, circulation
The loop repeats one thing, or it is called iterating or iterating, looping through the code in the loop body, and there are two loops while loops and for loops in Python.
1. While loop
You must have a counter to control the number of loops using the while loop
Break: Immediately ends the loop when a break is encountered in the while loop, and the break is the entire loop stop;
Continue: Meaning to jump out of this cycle, continue the next cycle, continue the following loop code does not execute, continue the next cycle
Random.randint generating random integers
2. For loop
The For loop does not require a counter, but it must have an iterative object in order to loop, such as an array, such as the range function
Seven, the format of
For example, welcome login Prompt "Welcome login, Lie Triple". Where lie triple name is variable, "Welcome to login" Unchanged, you can format the name of
Formatting methods are: 1) placeholder, such as:%s;2) Format function, 3) + number method, not recommended
%s string,%d integer,%f decimal, leave a few decimals on%.nf, such as two decimal places%.2f
You can use%s with any value,%d must be an integer,%f must be a decimal
Python Basics (i) Introduction & Getting Started & Conditions & Loops