The main part of the Rocks+Python Study Group is to learn to program in Python.We will cover the following topics in Python and Python’s extension modules:
- 00 General Info
- 01 First Steps with Python
- 02 Data Types and Variables
- 03 Lists and List Manipulations
- 04 Conditional Statements and Loops
- 05 Functions
- 06 Modules
- 07 Working with Files
- P1 Create a Program in Python to Generate the Fibonacci Sequence
- P2 Convert and Crop All Images in a Folder
- P3 Resize Images with Python PIL
Applications for programming and communications of Rocks+Python:
- Google Colab and Jupyter Notebook for coding
- Git and GitHub for version control and documentation
- Zoom for live sessions
- Discord for communicating
Topics for Rocks+Python:
- rocks, rock textures, rock classification and other related topics
- Python and NumPy, Matplotlib, Pandas, OpenCV, SciPy, PyTorch
- Python: variables, data structures, loops, functions, and classes
- data analysis
Key Notes on Python
The Dutch programmer Guido van Rossum created the first implementation in December 1989 and released it for the first time in 1991 (Morra, 2018). Here’s the official Python website: https://www.python.org/. The latest version is 3.9.1 as of Jan 22, 2021 (https://docs.python.org/release/3.9.1/index.html).
Python is a general-purpose programing language; Python was made for people whose daily job may have nothing to do with software development, but they code mainly to handle data. Python is different than other programming languages such as Java or Swift; Java or Swift are for software developers.
Python is an interpreted language and not a compiled language. C/C++ are compiled languages. Compilation involves translating human understandable code to machine code, the base level form of instructions that can be directly executed by the CPU. Instead of translating source code to machine code like C++, Python code is translated to bytecode. The bytecode is a low-level set of instructions that can be executed by an interpreter. Instead of executing the instructions on CPU, bytecode instructions are executed on a Virtual Machine. CPython means that the interpreter is implemented in C language. Similarly, JPython is a Pyhton interpreter implemented in Java.
Python is an Object-Oriented programming language. Object-Oriented programming is a programming paradigm based on the idea that objects, and not procedures, are at the center of a program as in traditional programming. Object-Oriented programming is based on Classes, from which Objects are instantiated. As an Object-Oriented programming language, Python allows its exceptional extensibility: Python can be used to glue together a vast range of existing software. Python’s Modular structure allows important advantages; Python can import fast libraries initially written in other languages such as NumPy. Each library, or module, can be imported with the command import, or a function can be extracted from a model by using from.
Key points on Python
- A Python program ends with .py.
- Python programs execute (which ends at the end of the line or at the next semicolon).
- Python programs are parsed before execution to check if syntactic errors exist and will not run until the errors are fixed.
- Python uses indentation to determine a loop or a function.
- Case matters: “IPython” is different than “Ipython”.
- Comments are started with the hash symbol “#”.
- Python is extensible. Libraries written in Python or in other languages such as C or Fortran can be efficiently and immediately imported as Modules.
Resources for Python
- Python website: https://www.python.org/
- Python Documentation: https://docs.python.org/release/3.9.1/index.html (Jan 22, 2021)
- Think Python 2e: https://greenteapress.com/wp/think-python-2e/
- Python Course: https://www.python-course.eu/
- Code Academy: https://www.codecademy.com/catalog/language/python
- Geo-Python: https://geo-python-site.readthedocs.io/en/latest/
- Pythonic Geodynamics by Gabriele Morra: https://www.springer.com/gp/book/9783319556802