Python: Difference between revisions

597 bytes added ,  20 December 2019
Line 49: Line 49:
====Array Indexing====
====Array Indexing====
[https://docs.scipy.org/doc/numpy/user/basics.indexing.html Scipy Reference]
[https://docs.scipy.org/doc/numpy/user/basics.indexing.html Scipy Reference]
===Lists===
The default data structure in Python is lists.<br>
A lot of functional programming can be done with lists<br>
<syntaxhighlight lang="python">
groceries = ["apple", "orange"]
groceries.reverse()
# ["orange", "apple"]
groceries_str = ",".join(groceries)
# "apple,orange"
groceries_str.split(",")
# ["apple", "orange"]
# Note that functions such as map, enumerate, range return enumerable items
# which you can iterate over in a for loop
# You can also convert these to lists by calling list() if necessary
enumerate(groceries)
# [(0, "apple"), (1, "orange")]
</syntaxhighlight>


===Filesystem Read and Write===
===Filesystem Read and Write===