Mentioned here a basic concept: the container may comprise --- to another object; is the sequence of the two main container (and a listing neuron progenitor) and mapping (dictionary)
General basics of sequence: sequence python commonly used are mainly two: ------- index lists and tuples, slicing, addition, multiplication and eligibility checking
1. Index: all elements of a sequence are numbered, starting from 0
names='xiaoyan'
Print (names [0])
Print (names [. 3])
Print (names [-1])
Results:
2. Section: access to a specific range of elements
= names 'Xiaoyan'
Print (names [0:. 3]) # specific range excluding the last element
Print (names [. 4:])
Print (names [:. 3])
Print (names [-3: -1]) # reverse
print (names [1: 6: 2]) # within [1,6) is the range of -2 steps, steps can be negative
print (names [:]) # copy
result:
3. The sequence is multiplied with the camera
Adding:
Names='lanwan'
LastNames='bantun'
[1,2,3]+[6,5,4]
print(LastNames+Names)
print([1,2,3]+[6,5,4])
Results: Note: The list and string can not be summed
Multiplying:
print ( 'python' * 5)
Results: pythonpythonpythonpythonpython
4. Membership examination:
names='bantunlanwan'
print('w' in names)
print('f' in names)
result:
The built-in function len max min
numbers=[123,45,67,97]
print(len(numbers))
print(max(numbers))
print(min(numbers))
result: