Python List Data Structure
(Redirected from Python List)
Jump to navigation
Jump to search
A Python List Data Structure is a Python array data structure that is a Python built-in data structure.
- Context:
- It can be an input to an List-input Python Subroutine, such as a Python Join Subroutine.
- It can be an input to a Python List Operation, such as a Python List Join.
- It can range from being a One-Dimensional Python List to being a Multi-Dimensional Python List (such as a two-dimensional Python list)
- Example(s):
list1 = ['physics', 'chemistry', 1997, 2000] ;
personList = [] ;
personList.append(Person("Payne Pinar", "coach")) ;
print personList[0].name ;- a Python List Comprehension, such as:
squares = [x**2 for x in range(10)] ;
- a Python List of Tuples for a tuple data structure, such as:
LoT = [(0,'a'), (1,'b'), (2,'c')]
- a Python List Vector for a vector data structure.
- a Python List of Lists (Python Matrix), such as:
LoL = [[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]
- a Python List of Dictionaries.
- …
- Counter-Example(s):
- a numpy.Array.
- a pandas.DataFrame.
- a Python Associative Array.
- a Perl Array (e.g. a Perl array of arrays).
- See: Python Coding Example, Python List Comprehension.
References
2016
- https://docs.python.org/3/tutorial/datastructures.html#more-on-lists
- QUOTE: The list data type has some more methods. Here are all of the methods of list objects:
list.append(x)
Add an item to the end of the list. Equivalent toa[len(a):] = [x]
.list.extend(L)
Extend the list by appending all the items in the given list. Equivalent toa[len(a):] = L
.- …
- QUOTE: The list data type has some more methods. Here are all of the methods of list objects:
2013
- (Melli, 2013-05-21) ⇒ Gabor Melli. (2013). “Python Array Examples."
- Populate manually
Matrix = [[0 for x in xrange(5)] for y in xrange(6)] Matrix[4][3] = 99 Matrix xx = numpy.array([2, 4, -11]) yy = zeros(3, Int) # Create empty array ready to receive result
- Populate from a file.
- Loops
for i in range(0, 3): Matrix[i] = i * 2 print yy # [4 8 -22]
- Transforming into a string
- Emptying
- Random
import random; #Generate 1000 random integer numbers which are between 1 and 9999(included). Z=random.sample(range(1,9999),1000); type(Z)