Python data type
1. Strings (String)
Use characters enclosed in "or"
2. Digital
· integer (int)
· floating point (float)
That is, the number with the decimal point 1.48 21 is an integer can be 21.0 or 21. Represents its floating-point numbers. 0.48 can also be expressed as. 48
· plural (complex)
3. List
4. Tuples
5. Dictionaries
#因为是第一天学, plural, list, tuple, dictionary have not studied
6. Boolean Value (Boolean)
True,false (1 or 0)
Different arithmetic rules for different data types
The addition of integers and the addition of strings have different meanings
#字符串能加 but don't give me a perfect explanation!
Different types of data are represented differently within computers
5 is represented as 101 ' 5 ' as 1001101
Why distinguish between integers and floating-point numbers
• Floating point number means more power
• Loss of floating-point numbers with precision
· CPU has specialized floating-point arithmetic parts
Operators and expressions
In Python2, "/" means a downward divide, that is, two integers, and the result is an integer, which is the fractional part
If one number is a floating point, the result is a float
Calculation of remainder (%)
10%3=1
such as: 10%3=1
Application
If today is Saturday, what is the day of the week after 10 days?
(6+10)%7=2
Determines whether a number x is even
x%2 is equal to 0
Relational operations
Determine if a number x equals 0
x%2 is equal to 0
x%2==0 #判断 = =
If True, X is an even number
If False, X is an odd number
Determine the relationship of two values in addition to the size of equal or unequal
Only two of the results of the operation (Boolean)
If the result is true, the condition is set
If the result is false, the condition is not established
Size can be compared between strings
logical operators
And and operations (Quanjin is True) True and False==false
or OR operation (all false) True or false==true
Not non-arithmetic (true change false, False true) not True==false
#这又是为啥?
Python Day 1 Data type