This article shows the blog posts written by vamei to the bloggers.
1. type () can display the parameter type, for example, a = 12 type (a) is int
2. the basic type of python is int float bool string such as int: I = 1, float: f = 12.5, bool: B = True or Flase, string: s = 'hello, word! 'No need to declare the type, that is, the dynamic type, before use
3.1 sequences include tuple and list. the tuple statement cannot be changed to s = (1, '3', True, (1, 2, 3 )) subscript starts with 0 s [0] as 1 s [3] [1] As 2 list declaration method is s = [1, 2, 3] can be nested value assignment change Delete and other operations
3.2 sequence subscript technique s [0: 3] means the last element of list from 0 to 2 (excluding 3) s [-1] list
3.3 string is tuple
4. operations include +,-, *,/, % addition, subtraction, multiplication, division, and remainder.
2) Yes = ,! =, <, >,<=, >=Equals, not equal to or less than, greater than, less than or equal to, greater than or equal ....
3) logical operations include and, or, not and, or not, that is, 1. are true. 2. One or more of them are true. 3. Reverse Lookup
5. Python uses a Tab as the indent (Tab) to indicate the indent relationship in the code below:
1 def Helloword():2 for i in gange(5):3 print('Hello word ',i)
2) def for while if else and other definitions are required: otherwise, the indentation print will be wrong, indicating that the statement is in the for statement.
6. while loop judge false Value Stop Loop
i=5while i : print(i) i=i-1
For Loop record Loop
For I in range (5): # gange returns a list. in to traverse the print (I) sequence)
If select Loop
1 if I <0: 2 print ('I is less than 0') 3 else: 4 print (' I is greater than or equal to 0 ')
Break jumps out of the entire loop. continue stops this loop.
7. Define the function to indent every line of code using def
Def test (a, B): # define the function print (a, B) test (1, 2) # Use the Function
A, B is the row parameter 1, 2 is the real Parameter