'' '
Why variable values (ie data records) to distinguish between type it?
Variable value used to record the state of affairs, and the state of things
are various, it should correspond with different types of values
to record the state
'' '
1, the string type
Action: recording status descriptive Definition: '' , '' , '' '' '' , "" "" "" comprises a string of characters in the name = ' Egon ' line string: '' , "" multi-line string: '' '' '' , "" "" "" MSG = "" " AAAA bbbb CCC " "" outer layer single quotes, inner layer should be enclosed in double quotes info = ' My name IS "Egon" ' Print (info)
2, integer
Role: Record age, number
defined way:
Age = 18
3, float
Action: height records, payroll, weight defined method: the salary = 3.1 height = 1.75 weight = 73.1
4, list (stored plurality of values corresponding to the index value, the index represents a position)
Action: in the order of storing a plurality of values, and the value can be taken in the order specified position defined: within [], separated by commas more of any type of value L = [ ' AAA ' , 10, 11.11, [ ' BBB ' , ' CCC ' ], ' ddd ' ] index starts from 0 Print (L [0]) Print (L [2 ]) reverse takes Print (L [-1 ]) Print (L [-2 ]) Print ( L [. 3] [. 1 ]) record the name of the class person school_names = "" " Tie egg Maruko King cannon Li scrape " "" school_names = [ "Li Tie egg small ball ' , ' King cannon ' , ' Lee Cha Cha ' ] Print (school_names)
5, a dictionary: a plurality of stored values, corresponding to the key value, usually descriptive function key should have a value, key string type usually
Definition: {}, separated by commas plurality of key: value element DIC = { ' XX ' : 111, ' yyy ' : 222 } Print (DIC [ ' XX ' ]) Print (DIC [ ' yyy ' ]) info = { " name " : ' Egon ' , " Age " : 18 is , " Sex " : ' MALE ' , " the salary " :. 1.75 } print(info["age"]) salaries=[11.1,22.222] print(salary[0])