1. Bsics

  1 #!/user/bin/env python
  2 # -*- coding:utf-8 -*-
  3 
  4 # Single-Line Comments
  5 
  6 """
  7 multiline Comments
  8 """
  9 
 10 """
 11 1. Variable
 12     Weak Type : No clear type, the specific type depends on the value
 13         number = 10
 14         print(type(number)
 15         number = "10"
 16         print(type(number))
 17 2. Statement of Variables
 18     format : Variable = value
 19     Naming rules for Variable:
 20         It can only be composed of letters, numbers and underscores
 21         Can not start with numbers
 22         Can not use keywords
 23             import keyword
 24             print(keyword.kwlist)
 25         Case-sensitive
 26         understand By name
 27 3. Types of Variables
 28     str : name = "YeYuanXinZhiZhu" 
 29           msg = '''
 30                 Use three quotation marks in reserved format
 31                 '''
 32           Predefined escape characters
 33                 \\, \',  \", \r, \t, \n
 34                 combine with "r", keep the original format
 35                     string = r"hello \table"
 36     int : salary = 499999
 37     float : salary = 499999.99
 38     bool : flag = True, flag = False
 39     byte : b = b"hello"
 40     Unique types of Python (Container) :
 41         list : scores = [90, 81, 51, 100, 69]
 42         tuple : scores = (90, 81, 51, 100, 69)
 43         set : scores = {90, 81, 51, 100, 69, 90, 81}
 44             duplicate elements are not allowed
 45         dict : scores = {"GeBiCunGaHa": 90, "YeYuanXinZhiZhu": 81}
 46 4. Use of Variables and Operators
 47         Arithmetic Operators : + - * / % ** //
 48         Assigment Operators : = += -= /= %=
 49         Relational Operators : == != > < >= <= is
 50         Logical Operators : and or not
 51             Tt is the case of False : "" 0 None
 52         Bitwise Operators :
 53             binary : a = 0b01000101
 54             octal : b = oct(a)
 55             decimal : c = int(a)
 56             hexadecimal : d = hex(a)
 57 
 58             computer operations :
 59                 converting -3 to binary :
 60                     converting 3 to binary :
 61                         original code : 0000 0011
 62                     Invert code of 3 :
 63                         inverse coed : 1111 1100
 64                     Invert code of 3 + 1 :
 65                         complement code : 1111 1101
 66 
 67                 bit operation : & | ~
 68                                 ^(same is false, different is true)
 69                                 >> <<
 70             Member Operators : in, not in
 71             Identity Operators : is, is not
 72             Ternary Operators : [] if [] else []
 73 
 74 5. Sentence
 75     Conditional Statement
 76         if conditional:
 77             pass
 78         else:
 79             pass
 80 
 81         Multiple Conditional Judgment:
 82             if conditional:
 83                 pass
 84             elif conditional:
 85                 pass
 86             elif conditional:
 87                 pass
 88             else:
 89                 pass
 90 
 91             scene :
 92                 Parking Management System
 93                 Bank Management System
 94     Loop Statement
 95         Avoiding death circle:
 96             Modify circle conditions;
 97             Set the end condition in the loop body
 98 
 99         while conditions:
100             loop body
101 
102         while conditions:
103             loop body
104         else:
105             pass
106 
107         for i in [iterable object]
108             loop body
109 
110         for i in [iterable object]
111             loop body
112         else:
113             pass
114     Goto Statement
115         break : jump out of the loop structure
116         continue : skip the circle and continue with the next one
117 """

 

posted @ 2019-08-06 17:27  隔壁村嘎哈  阅读(195)  评论(0编辑  收藏  举报