Python's built-in data types are numbers, strings, lists, tuples, and dictionaries
1. Integer and floating point
It can be seen from this that the type of variables can be changed. When Python assigns an existing variable a value, it actually creates a new variable again. Even if the variable names are the same, their identifiers are different. The identifier can be identified using the id function. output
2. Boolean
Boolean is used for logical operations. There are two values, true and false. The identification is true and false. In fact, it is no
different from Java.
3. Python operators
(1) The arithmetic operators used in Python are basically the same as the operators in mathematics. They are
composed of +, -, *, / and parentheses. The order of operations is multiplication and division followed by addition and subtraction. The parentheses are calculated first. . Here are some examples to illustrate:
(2) There are also two arithmetic operators, % and **, (modulo operation and exponentiation operation). Modulo operation is to take the remainder, and exponentiation is a cumulative multiplication. As a result, the sample code is as follows
It's easy to understand if I don't say much here. Let me add that Python does not support the auto-increment operator ++ and the auto-decrement operator--
4. Use of Python strings
(1) There are three ways to represent strings in Python: single quotes, double quotes, and triple quotes. Examples are as follows:
(2) Other uses of
strings Python strings can be multiplied. You can multiply an integer with a string, such as multiplying a string 'a' with a number 6. The structure is a string aaaaaa, which is equivalent to copying a string a 6 times, the code is as follows: