Python review path-Day01, python path-day01
1. Number
2 is an integer example.
A long integer is a larger integer.
3.23 and 52.3E-4 are floating point numbers. E indicates the power of 10. Here, 52.3E-4 indicates 52.3*10-4.
(-5 + 4j) and (2.3-4.4.7) are examples of plural numbers. Where-5 and 4 are real numbers, j is virtual numbers, and what is the plural in mathematics ?.
Int (integer)
On a 32-bit machine, the number of digits of an integer is 32 bits and the value range is-2 ** 31 ~ 2 ** 31-1, I .e.-2147483648 ~ 2147483647
In a 64-bit system, the number of digits of an integer is 64-bit, and the value range is-2 ** 63 ~ 2 ** 63-1, that is,-9223372036854775808 ~ 9223372036854775807 long (long integer)
Different from the C language, the Length Integer of Python does not specify the Bit Width. That is, Python does not limit the size of the Length Integer. However, due to limited machine memory, the length integer value we use cannot be infinitely large.
Note: Since Python2.2, if an integer overflows, Python will automatically convert the integer data to a long integer. Therefore, without the letter L after the long integer data, it will not cause serious consequences.
Float (float type)
Advanced Literacy http://www.cnblogs.com/alex3714/articles/5895848.html
Floating point numbers are used to process real numbers, that is, numbers with decimals. Similar to the double type in C, it occupies 8 bytes (64-bit), where 52 bits represent the bottom, 11 bits represent the index, and the remaining one represent the symbol.
Complex (plural)
A complex number is composed of a real number and a virtual number. Generally, x + yj is used. x is the real number of a complex number, and y is the virtual number of a complex number. Here, x and y are both real numbers. Note: there is a small number pool in Python:-5 ~ 257 2. boolean value true or false 1 or 03, string
"hello world"
String concatenation: a string in python is a character array in C. Each time you create a string, you need to open a continuous empty string in the memory. Once you need to modify the string, it is necessary to open up space again. Every time the "+" icon appears, it will open up a space from it.
String formatting output
1234 |
name = "alex" print "i am %s " % name # Output: I am alex |
PS: string is % s; integer % d; floating point % f
Common functions of strings:
- Remove Blank
- Split
- Length
- Index
- Slice
4. list creation list:
123 |
name_list = [ 'alex' , 'seven' , 'eric' ] Or name_list = list ([ 'alex' , 'seven' , 'eric' ]) |
Basic operations:
- Index
- Slice
- Append
- Delete
- Length
- Slice
- Loop
- Include
5. Create tuples (immutable list:
123 |
ages = ( 11 , 22 , 33 , 44 , 55 ) Or ages = tuple (( 11 , 22 , 33 , 44 , 55 )) |
6. Create a dictionary (unordered:
123 |
person = { "name" : "mr.wu" , 'age' : 18 } Or person = dict ({ "name" : "mr.wu" , 'age' : 18 }) |
Common Operations:
- Index
- New
- Delete
- Key, value, and key-Value Pair
- Loop
- Length