Python Introduction
The founder of Python is Guido van Rossum (Guido van Rossum). 1989 Christmas period, Guido van Rossum (Chinese name: Uncle Turtle) in order to pass time in Amsterdam, determined to develop a new script interpreter, as an inheritance of the ABC language.
The July 2017 Tiobe leaderboard, Python has taken the fourth place, Python's elegance, clarity, and simplicity is an excellent and widely used language.
Python application areas
- Cloud computing : The hottest language in cloud computing, typically using OpenStack
- Web Development : A number of excellent web frameworks, many large sites are Python development, Youtube, Dropbox, watercress ... , a typical web framework has Django
- Scientific Computing, artificial intelligence : Typical library numpy, SciPy, matplotlib, Enthought Librarys,pandas
- system Operation and maintenance: the necessary language for operation and maintenance personnel
- Finance : Quantitative trading, financial analysis, in the field of financial engineering, Python is not only used, but also used the most, and the importance of the year. Reason: As a dynamic language Python, the language structure is clear and simple, the library is rich, mature and stable, scientific calculation and statistical analysis are very good, production efficiency is much higher than c,c++,java, especially good at strategy backtesting
- graphical GUI: PyQT, Wxpython,tkinter
Compilation and introduction of Pyhon
CPython: interpreted as C language machine code
Jpython: Interpreted as a Java language byte code
Ironpython: interpreted as C # language bytecode
PyPy: Interpreted as JIT-on-the-fly compilation
Python single-line comments and multiline comments
Single-line comment with "#" in front of content
多行注释 ‘‘‘被注释的内容‘‘‘ 或者 """被注释的内容"""Concatenation of strings
The string can only be +, *;
String "+" operation
Boolean value (True, False)
The Boolean value is simple, contains only two values, one represents true (true), one represents false (false)
I now have 2 values, a=3, b=5, I say a>b you say set up? Of course we know it doesn't, but the question is how does a computer describe it as a non-establishment? Or that a< B is set up, how does the computer describe it? Yes, the answer is the Boolean type.
赋值运算
Suppose variable: a = 1,b = 3
1 i = <= 10:3 4 if I==7:5 i+=16 continue7 Print (i) 8 i+=1
Logical operations
Judgment Statement (IF)
If you write a program than do walk, we have so far, have been walking straight, have not encountered too much fork, imagine the reality, you encounter a fork, and then you decide where to turn must be motivated. You have to judge that fork is the way you really want to go, if we want to let the program can also handle such a judgment what to do? Very simple, just need to preset some conditions in the program to judge the sentence, to meet which conditions, the road fork. This process is called Process Control.
Single Branch
1 If condition: 2 code to execute after condition is met
Dual Branch
1 If condition: 2 code that satisfies the conditional execution 3 else:4 If condition does not satisfy go this paragraph
1 score = 702 If score >= 60:3 print ("Pass") 4 Else:5
Multiple branches
If condition: satisfies the condition to execute the code elif condition: The above condition does not satisfy to go this paragraph elif condition: above condition does not satisfy to go this section elif condition: above condition does not satisfy to go this paragraph else: All the above conditions are not satisfied.
1 age = 482 3 guess = int (input ("Please enter the ages you want to guess:")) 4 if guess > age:5 print ("Guess big, try the little Li ...") 6 7 Elif Guess < age:8
print ("Guess small, go to Dali Try ...") 9 Else:print ("Congratulations, you guessed right")
Looping statements
- In general, code that requires repeated executions can be done in a circular way
Cyclic termination conditions:
- The Break keyword
- Changing the while loop condition
- Continue
.... While condition: when conditions are met, do things 1 conditions meet, do things 2 conditions meet, do things 3 conditions are not satisfied, jump out of the loop, execute while the following code ....
Continue keywords
For example, print 1-10, but do not print 7, 1,2,3,4,5,6,8,9, 10, you can use continue, when the variable equals 7, jump out of this cycle, the next cycle
i = 1while I <=: if i==7: i+=1 continue print (i) i+=1
The Break keyword
i = 1while I <=: if i==7: Break Print (i) i+=1
Only executes to 7, interrupts the loop, and the subsequent array no longer prints the output.
Python 1.19