table of Contents
1.1 int type
Description: int () function is used to convert a string or an integer number.
Syntax: age = 10 ~ actual code: age = int (10)
1.2 float float
Description: a float () function is used to convert the integer to floating point and string.
Is defined:
height = 178.5 ~ actual code: height = float (178.5)a = float (112) ~ print result: 112.0
1.3 complex
Complex is composed of a real number and an imaginary number combination, expressed as: x + y
aa=123-12j
print aa.real # output the real part of
the output: 123.0print aa.imag # output the imaginary part of
the output: -12.0
2.1 String role
Python string is the most commonly used data types. We can use quotation marks ( 'or') to create a string.
2.2 string definitions
Assign a value to a variable, to create a string in quotes:
var1 = 'Hello python' # single quote
var2 = "2020" # double quotes
var3 = '' '
2020
Happy New Year
' '' # triple quotes can be in a new line
2.2 Use string
3.1 Role boolean
Two states used to record the true and false
True true
Flase false
The definition of a Boolean value 3.2
>>> is_ok = True
>>> is_ok = False
Boolean value of 3.3
Analyzing conditions as usually, while common in the for loop, and if determination
4.1 List of action
For storing an ordered, with the attribute, a plurality of values
is essentially a set of ordered
4.2 List of definitions
Python sequence is the most basic data structure. Each element in the sequence is assigned a number - its position, or index, the first index is 0, the second index is 1, and so on.
= List1 [ 'Physics', 'Chemistry', 1997, 2000]
List2 = [. 1, 2,. 3,. 4,. 5]
list3 = [ "A", "B", "C", "D"]
4.3 List of use
5.1 Role dictionary
If there is no law between multiple values, the value of a variable value to be recorded by the index value is not clear that the meaning of this time is necessary to use dictionary
key- Description Value value- stored value
5.2 dictionary definition
dict1 = { 'abc': 456 }
dict2 = { 'abc': 123, 98.6: 37 }
5.2 Use a dictionary
6: tuple
Complete mind map (requires source files, send email leave comments)