- Originally wanted to write some machine learning algorithm implementation of the article, but found that their work experience is not enough, even if written out, but also only a few application scenarios very narrow small experiment;
- Know that some friends and classmates also want to learn about scripting language Python (after all, is a rising star), paper, electronic resources everyone has, but always feel the strength of learning, is not a small partner to learn it;
- In conclusion, I intend to write a series of Python tutorials focusing on the basics of machine learning and deep learning.
- This may seem like a trivial job for others, but for me it is not only a test of my past Python learning, but also a challenge to my current time management, to fully, systematically and focus on Python knowledge.
- I'll keep on going! Welcome to leave a message harassment, joy, capacity limits, welcome advice.
- Experimental environment: Python 3.6;
- Complete example of this article: Download sample
features of Python
- Object-oriented interpretative language;
- Simple and easy to learn;
- a rich library;
- Forces the use of tabs as a statement indent (white space).
the pros and cons of Python
- Advantages
- Simple, easy to learn;
- free, open source;
- scalability, embeddable;
- A rich library.
- Disadvantages
- Running slowly;
- Lack of Chinese information;
- The code cannot be encrypted.
Anaconda Installation and configuration
Anaconda is highly recommended, an integrated development environment that integrates many common Python libraries, eliminating the complexity of the development environment configuration, allowing us to concentrate on learning real technology. Praise
- :
The domestic Tsinghua Mirror, the speed drops quickly.
Note Choose a version number that corresponds to your computer.
Installation method: All the way next.
- Jupyter Notebook Related configuration
- Configure the default startup directory: Configuration method
installation and configuration of Pycharm
- Download installation
Official
Installation method: All the way next.
- To register a server:
Server option inside input http://elporfirio.com:1017/
Or: Enter http://idea.imsxm.com/inside the server option
Use the activation code of the small partner point here to copy the activation code.
- Pycharm of Chinese
If the level of English OK, it is not recommended to Chinese.
Pycharm Chinese Package
Copy Resources_cn.jar The Lib folder placed in the Pycharm installation directory.
python comment Syntax
- The role of annotations
- Increase the readability of the program;
- used as debugging;
- Improve the team's cooperation efficiency.
- Classification of annotations
- Single-line comment;
begins with the symbol #, which indicates that the contents of the current line are commented.
- Multi-line annotations;
- is represented by three pairs of single quotes
‘‘‘多行注释‘‘‘ .
variables in Python
- What is a variable?
The amount used to store the data.
- What is an identifier?
Identifiers are user-defined, such as variable names, function names, and so on.
- Naming rules for identifiers
- Can only contain letters, numbers, and underscores;
- You can only start with a letter or underscore, and you cannot use numbers at the beginning;
- Cannot contain spaces, you can use underscores to split words;
- You cannot use a keyword in python as the variable name;
- Python is strictly case sensitive;
- It is recommended to use the Hump naming method:
- Large hump: VariableName;
- Small hump: VariableName.
- Common keywords
View python keywords in python
in[2] :Importkeywordin[3]: keyword.kwlistout[3]: [' False ',' None ',' True ',' and ',' as ',' assert ',' Break ',' class ',' Continue ',' def ',' del ',' Elif ',' Else ',' except ',' finally ',' for ',' from ',' Global ',' If ',' Import ',' in ',' is ',' Lambda ',' nonlocal ',' not ',' or ',' Pass ',' Raise ',' return ',' Try ',' while ',' with ',' yield ']
Data Type
- number
- int integer;
- float float;
- complex complex;
- bool Boolean.
- string string
- str = "ABCD";
- str = ' AB ' + ' CD '; The plus sign enables concatenation of strings;
- string can be indexed and sliced, and slices follow left open right.
- List List
- list is placed between square brackets, elements are separated by commas,
- is indexed and sliced like a string, and slices follow the left The
- list can be stitched using the plus (+) operation, and the elements in the
- list can be changed.
- tuple tuples
- tuple elements cannot be changed;
- tuples can contain mutable objects, such as list;
- composition 0 Special syntax for tuples of one or 1 elements:
- tuple1= () #空元祖
- tuple2= (1,) #一个元素, you need to add a comma after the element
- Sets collection
- deterministic;
- cross-specific;
- unordered.
- Dictionary dictionary
- Dictionary is a type of mapping, the element is a key-value pair; the
- key (key) must use a data type that cannot be changed (string, value, tuple), the key (key) must be unique in the same dictionary;
operator
- Arithmetic operators
- Plus +: two numbers added;
c = a + b
- Minus-: two number subtraction;
c = a - b
- Multiply by *: two numbers multiplied;
c = a * b
- Divide by/: two numbers;
c = a / b
- Modulus (residual)%: Returns the remainder of the two-digit division;
c = a % b
- Power: power operation; equivalent built-in function pow (a, b);
c = a ** b
- Take divide//: Take the integer part of two number division.
c = a // b
- Assignment operators
- equals =: Equal value assignment;
- Addition Assignment = =: First do the addition operation and then assign the value;
- Subtraction Assignment + =: first do subtraction and then assign value;
- Multiplication Assignment *=: first do multiplication and then assign value;
- Division assignment/=: first do division operation and then assign value;
- The assignment value of%=: The first is to do the residual operation and then assign the value;
- Power Assignment
**= : The first power operation and then the value;
- The assigned value//=: Divide first and then assign value.
- Comparison operators
- equals = =
- Greater than >
- Less than <
- Greater than or equal to >=
- Less than or equal to <=
- logical operators
- With: and
if condition1 and condition2:
- Or: OR
if condition1 or condition2:
- Non: not
if not condition:
| Bitwise operations in Python |
- Bitwise operators
- Bitwise AND Arithmetic &: in bits, the corresponding position is 1 to 1, the other case is 0;
- Bitwise OR Operation | : In the bits, the corresponding position is 0 to 0, all other cases have 1;
- Bitwise XOR OR operation ^: bits, the corresponding position of the same 0, the difference is 1;
- Bitwise INVERSE OPERATION ~: bitwise negation; Note that negative numbers are stored in complementary form, and when converted to decimal, the first (sign bit) is unchanged, the other bits are reversed, the bottom +1.
- Left shift Operation <<:
a << b A left shift b bit, high drop, low 0;
- Right Shift arithmetic >>:
a >> b represents a right shift b bit, the left empty bit is filled with 0 or 1.
- Positive numbers are filled with 0, and negative numbers are filled with 1.
- Example:
The following only gives examples of left and right shift operations ha
# # # Left SHIFT and right shift operation# # Output binary digitsA= theB= 3Print("%dThe binary is:%s" %A"{: b}".format(a). Rjust (8,' 0 ')) )Print("%dThe binary is:%s" %(b,"{: b}".format(b). Rjust (8,' 0 ')) )# Shift A to the left B bitPrint(' =* '*Ten,' Move A to the left B-bit ',' =* '*Ten) L3=A<<BPrint("%dThe binary is:%s" %(L3,"{: b}".format(L3). Rjust (8,' 0 ')) )# Shift A right to B-bitPrint(' =* '*Ten,' Shift a right to B-bit ',' =* '*Ten) R3=A>>BPrint("%dThe binary is:%s" %(R3,"{: b}".format(R3). Rjust (8,' 0 ')) )# # Negative left and right shift operationC= -7Print("\ n%dThe binary is:%s" %(b,"{: b}".format(b). Rjust (8)) )Print("%dBinaries are:%s" %C"{: b}".format(c). Rjust (8)) )# Shift C to the left B-bitPrint(' =* '*Ten,' Shift C to the left B bit ',' =* '*Ten) Nl3=C<<BPrint("%dThe binary is:%s" %(Nl3,"{: b}".format(NL3). Rjust (8)) )# Shift C to the right B-bitPrint(' =* '*Ten,' shift C to the right B-bit ',' =* '*Ten) NR3=C>>BPrint("%dThe binary is:%s" %(NR3,"{: b}".format(NR3). Rjust (8)) )
Output:
== = = == == = = = Left shift and right shift operation= = = = = = = = = = =
The binary of 15 is: 00001111
The binary of 3 is: 00000011
= = = = = = = = = = = = Shift A To the left b bit= == = = = = = ===
The binary of 120 is: 01111000
= = = = = = = = = = = = Shift a right to Bbit = = == = = = = ===
The binary of 1 is: 00000001
The binary of 3 is: 11
-72 Binary:-111
= = = = = = = = = = = Shift C to the left Bbit = = == = = = = ===
-56 of the binary is:-111000
= = = = = = = = = = = Shift C Right to b bit= == == = = = ===
-1 of the binary is:-1
- Complete example of this article: Download sample
- This paper introduces the construction and configuration of the environment, recommends Anaconda, and explains some of the basic concepts, data types, arithmetic operators, and logical operators in Python. Light said do not practice false bashi, so, more hands, the code! Come on.
- Limited capacity, welcome to the wrong communication; if it feels good, the lower right corner supports ha. ^-^
Welcome to the personal public number Waltsmithml or Sina Weibo waltsmith, my main direction for machine learning and deep learning. Very warmly welcome to exchange study ha, in addition to study, but also free to help download paper or books ha ==============
??? Public number????????? Sina Weibo???
Python first Knowledge--basic