1. python variables
<1> Variable definition: The variable name is defined only when it appears for the first time. When it reappears, instead of defining the variable, the previously defined variable is used directly. A variable is an address space. When a value is assigned to a variable, this value is put in, and the memory space is released when the value of the variable is deleted.
<2> Variable naming rules: Variables are composed of numbers, letters, and underscores. They cannot start with a number, and cannot be the same as keywords.
Such as: first_name (correct), first name (error), 4first (error) print, etc.
<3> Representation of variables: big camel
peak method (commonly used) and small camel peak Big head peak is the capitalization of the first letter of each word: FirstName
small head peak is the lowercase of the first word, and subsequent words capitalized: firstName
<4> Note the naming of variables: try to be as famous as possible
Example 1:
Test questions: The
results are as follows:
2. Data type
<1> int
Python2 has integer and long integer types, Python has no long integer type
Among python2: In
python3:
<2> float decimal type, floating point type
<3> str string
<4> bool boolean True (true), False (false)
3. Data type conversion
Note: Integer and floating point types can be converted to each other. Both integer and floating point types can be converted to character types, but character types cannot be converted to integer or floating point types.