Python

Hans-Petter Halvorsen

What is Python?

Python is an open source and cross-platform programming language, that has become increasingly popular over the last ten years. It was first released in 1991. CPython is the reference implementation of the Python programming language. Written in C, CPython is the default and most widely-used implementation of the language.

Python is a mult-purpose programming languages (due to its many extensions), examples are scientific computing and calculations, simulations, web development (using, eg., the Django Web framework), etc.

The programming language is maintained and available from (Python Software Foundation):

https://www.python.org

Here you can download the basic Python features in one package, which includes the Python programming language interpreter, and a basic code editor, or an integrated development environment, called IDLE.

 

Below you find Python Resources within different Topics:

 

Introduction to Python

See the following video to get a short introduction to Python:

PowerPoint used in the video

 

Textbooks

Read the following textbooks for more information about Python (just click the cover images below in order to open and download the different textbooks):

 

 

Python Programming

ISBN: 978-82-691106-4-7

Python Programming is a textbook in Python Programming with lots of Practical Examples and Exercises. You will learn the necessary foundation for basic programming with focus on Python. This textbook is written in LaTeX.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources that explaining and complements the different Python topics and examples within the textbook:

Introduction to Python (YouTube) + PowerPoint (PDF)

Basic Python Programming (YouTube) + PowerPoint (PDF)

Python Programming (YouTube) + PowerPoint (PDF)

Plotting with Python (YouTube) + PowerPoint (PDF)

Create Functions with Python (YouTube) + PowerPoint (PDF)

File Handling in Python (YouTube) + PowerPoint (PDF)

Mathematics in Python (YouTube) + PowerPoint (PDF)

Create Classes in Python (YouTube) + PowerPoint (PDF)

 

You find also all the videos above in this YouTube Playlist (Python Programming)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

 

Python for Science and Engineering

ISBN: 978-82-691106-5-4

Python for Science and Engineering is a textbook in Python Programming with lots of Examples, Exercises, and Practical Applications within Mathematics, Simulations, etc. The focus is on numerical calculations in mathematics and engineering. Necessary theory is presented in addition to many practical examples. This textbook is written in LaTeX.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources explaining and complements the different Python topics and examples within the textbook:

Mathematics and Science:

Solving Linear Equations with Python (YouTube) + PowerPoint (PDF)

Interpolation in Python (YouTube) + PowerPoint (PDF)

Curve Fitting in Python (YouTube) + PowerPoint (PDF)

Least Square Method in Python (YouTube) + PowerPoint (PDF) - Not made yet

Optimization in Python (YouTube) + PowerPoint (PDF)

Linear Algebra in Python (YouTube) + PowerPoint (PDF)

Differential Equations in Python (YouTube) + PowerPoint (PDF)

Numerical Differentiation in Python (YouTube) + PowerPoint (PDF)

Numerical Integration in Python (YouTube) + PowerPoint (PDF)

 

Simulations:

Discrete Systems with Python (YouTube) + PowerPoint (PDF)

Mass-Spring-Damper System with Python (YouTube) + PowerPoint (PDF)

 

DAQ:

DAQ with Python (YouTube) + PowerPoint (PDF) - Exemplified by reading Temperature Data using NI USB TC-01 Thermocouple

DAQ with I/O Modules in Python (YouTube) + PowerPoint (PDF) - Exemplified by using NI USB-6008 I/O Module

Sensors and Actuators with Python (YouTube) + PowerPoint (PDF)

TMP36 Temperature Sensor with Python (YouTube) + PowerPoint (PDF)

Thermistor Temperature Sensor with Python (PDF)

Light Sensors with Python (PDF)

Push Buttons with Python (PDF)

 

You find also all the videos above in this YouTube Playlist (Python for Science and Engineering)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

 

Python for Control Engineering

Python for Control Engineering is a textbook in Python Programming with lots of Examples, Exercises, and Practical Applications within Mathematics, Simulations, Control Systems, DAQ, Database Systems, etc. The focus is on the use of Python within measurements, data collection (DAQ), control technology, both analysis of control systems (stability analysis, frequency response, ...) and implementation of control systems (PID, etc.). Required theory is presented in addition to many practical examples and exercises in Python. This textbook is written in LaTeX.

This textbook is available as an "Early Preview" edition.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources explaining and complements the different Python topics and examples within the textbook:

Python for Control Engineering (YouTube) + PowerPoint (PDF)

 

Control Theory:

Transfer Functions with Python (YouTube) + PowerPoint (PDF)

State Space Models with Python (YouTube) + PowerPoint (PDF)

Frequency Response with Python (YouTube) + PowerPoint (PDF)

Stability Analysis of Control Systems with Python (PDF)

Simulation and Control with Python (YouTube) + PowerPoint (PDF)

 

Control System:

Control Systems with Python (PDF)

Control Systems with Python - Part 2 (PDF)

 

OPC:

OPC UA in Python (YouTube) + PowerPoint (PDF)

 

You find also all the videos above in this YouTube Playlist (Python for Control Engineering)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

 

Python for Software Development

Python for Software Development is a textbook in Python Programming with lots of Examples, Exercises, and Practical Applications within Software Systems, Software Development, Software Engineering, Database Systems, Web Application Desktop Applications, GUI Applications, etc. The focus is on the use of Python for creating modern Software Systems. Required theory is presented in addition to many practical examples and exercises in Python. This textbook is written in LaTeX.

This textbook is available as an "Early Preview" edition.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources explaining and complements the different Python topics and examples within the textbook:

Python for Software Development (YouTube) + PowerPoint (PDF) - Not made yet

 

Python with Visual Studio (YouTube) + PowerPoint (PDF) - Not made yet

Python Integration with LabVIEW (YouTube) + PowerPoint (PDF)

 

GUI/Desktop Programming:

Python PyQt GUI Development (YouTube) + PowerPoint (PDF) - Not made yet

 

Database Development:

Python and SQL Server (YouTube) + PowerPoint (PDF)

Python and Microsoft Azure Databases (PDF)

Python and MySQL (YouTube) + PowerPoint (PDF) - Not made yet

 

Python and MongoDB (YouTube) + PowerPoint (PDF)

MongoDB Cloud and Python (YouTube) + PowerPoint (PDF)

 

 

Raspberry Pi:

Raspberry Pi (YouTube) + PowerPoint (PDF)

Raspberry Pi with Python (YouTube) + PowerPoint (PDF)

Raspberry Pi GPIO with Python (PDF)

Raspberry Pi using SPI and I2C with Python (PDF)

Raspberry Pi and CircuitPython (PDF)

 

micro:bit:

micro:bit and Python (PDF)

 

Internet of Things (IoT):

MQTT with Python (YouTube) + PowerPoint (PDF)

 

Web Programming:

Python Fjango, Flask, etc. Tutorials and Videos may come later.

 

You find also all the videos above in this YouTube Playlist (Python for Software Development)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

 

Raspberry Pi and Python

Raspberry Pi and Python is a textbook where you learn about Raspberry Pi and Python Programming with lots of Examples, Exercises, and Practical Applications. The focus is on the use of Python in combination with Raspberry Pi. Required theory is presented in addition to many practical examples and exercises in Python. This textbook is written in LaTeX.

This textbook is available as an "Early Preview" edition.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources explaining and complements the different Python topics and examples within the textbook:

Getting Started with Raspberry Pi:

Raspberry Pi (YouTube) + PowerPoint (PDF)

Raspberry Pi Installation and Remote Access (YouTube) + PowerPoint (PDF)

 

Installing Python packages on Raspberry Pi:

Python is installed by default as a "system-wide" installation as part of the Raspberry Pi OS and by default in the latest version of Raspberry Pi OS you cannot install Python packages in the global Python ("system-wide" installation) environment on Raspberry Pi OS. This is due to security reasons and the fact that you can destroy this environment by installing new packages which can cause other programs on Raspberry Pi OS to no longer work.

You have then several options when installing Python packages on Raspberry Pi:

  • Alt 1. You can run "sudo apt-get install python3-packagename" from the Terminal in Rasperry Pi OS to still install packages "system-wide".
  • Alt 2. You can create a new Virtual Python Environment on the Raspberry Pi. This is the recommended alternative as you do not destroy other programs or the system-wide Python environment. This can be done in several ways, but the easiest way is to do it from the graphical environment in Thonny, alternatively from the Terminal.
  • Alt 3. You can switch off the default setting which allows you to install Python packages "system-wide" in the usual way using pip/Terminal or from Thonny.

Installing Python Packages on Raspberry Pi (YouTube) + PowerPoint (PDF)

 

Raspberry Pi + Python:

Raspberry Pi with Python (YouTube) + PowerPoint (PDF)

Raspberry Pi GPIO with Python (PDF)

Raspberry Pi using SPI and I2C with Python (PDF)

Raspberry Pi and CircuitPython (PDF)

 

Sensors:

Raspberry Pi and AM2320 Temperature and Humidity Sensor with I2C Interface (PDF)

Raspberry Pi and AM2320 - Testing different existing Libraries (PDF)

 

Raspberry Pi Pico:

Here you find additional Raspberry Pi Pico resources.

 

You find also all the videos above in this YouTube Playlist (Raspberry Pi and Python)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

 

Internet of Things with Python

Internet of Things with Python is a textbook where you learn about Internet of Things (IoT) and Python Programming with lots of Examples, Exercises, and Practical Applications. The focus is on the use of Python in Internet of Things Applications. Required theory is presented in addition to many practical examples and exercises in Python. This textbook is written in LaTeX.

This textbook is available as an "Early Preview" edition.

You find Source Code and additional Resources below.

 

Resources

Below you find different resources explaining and complements the different Python topics and examples within the textbook:

Raspberry Pi:

Raspberry Pi (YouTube, Not made yet) + PowerPoint (PDF)

Raspberry Pi with Python (YouTube) + PowerPoint (PDF)

Raspberry Pi GPIO with Python (PDF)

Raspberry Pi using SPI and I2C with Python (PDF)

Raspberry Pi and CircuitPython (PDF)

 

Raspberry Pi Pico:

Here you find additional Raspberry Pi Pico resources.

 

micro:bit:

micro:bit and Python (PDF)

 

MQTT:

MQTT with Python (YouTube) + PowerPoint (PDF)

 

Database Systems:

Python and SQL Server (YouTube) + PowerPoint (PDF)

Python and Microsoft Azure Databases (PDF)

Python MQTT, SQL Server and Microsoft Azure (PDF)

Python and MongoDB (YouTube) + PowerPoint (PDF)

MongoDB Cloud and Python (YouTube) + PowerPoint (PDF)

 

You find also all the videos above in this YouTube Playlist (Raspberry Pi and Python)

 

Not all resources are ready at the moment, but new resources are released continuously. Stay tuned!

 

 

Note! These are "working documents" that are more or less updated continuously with new contents. See the Questions and Comments section if you have questions, if you find bugs or want new topics, examples, etc.

 

 

 


 

Python Resources

Below you find lots of resources regarding Python.

 

Python Code Examples

Python Code Examples - From the Textbooks above.

 

Python Tutorials

Here are some Python Tutorials:

 

Python Packages

Rather than having all of its functionality built into its core, Python was designed to be highly extensible. This approach has advantages and disadvantages. An disadvantage is that you need to install these packages separately and then later import these modules in your code.

These packages need to be downloaded and installed separately, or you choose to use, e.g., a distribution package like Anaconda.

Some important packages are:

Lots of other packages exists, depening on what you are going to solve.

 

Anaconda

Anaconda includes Python, the Jupyter Notebook, and other commonly used packages for scientific computing and data science.

They offer a free version (Anaconda Distribution) and a paid version (Enterprise)

Anaconda is available for Windows, macOS, and Linux 

 

Web: https://www.anaconda.com

Wikipedia: https://en.wikipedia.org/wiki/Anaconda_(Python_distribution)

 

Spyder and the Python packages (NumPy, SciPy, matplotlib, ...) mention above +++ are included in the Anaconda Distribution.

 

 

Python Editors

An Editor is a program where you create your code (and where you can run and test it). Most Editors have also features for Debugging.

For simple Python programs you can use the IDLE Editor, but for more advanced programs a better editor is recommended.

Examples of Python Editors:

 

Spyder

Spyder is an open source cross-platform integrated development environment (IDE) for scientific programming in the Python language.

Web: https://www.spyder-ide.org

Wikipedia: https://en.wikipedia.org/wiki/Spyder_(software)

Spyder is included in the Anaconda Distribution.

 

Visual Studio Code

Visual Studio Code is a multi-purpose source code editor developed by Microsoft for Windows, Linux and macOS.

Web: https://code.visualstudio.com   

Resources:

 

Thonny

Python IDE for beginners. A very simple and basic Python Editor. Highly recommended! Here you can easily install Python Libraries/Packages using a Graphical User Interface (no PIP commands needed). Thonny is also the default Python Editor on the Raspberry Pi OS.

Web: https://thonny.org

Wikipedia: https://en.wikipedia.org/wiki/Thonny

 

 

Visual Studio

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs, as well as websites, web apps, web services and mobile apps. The deafult (main) programming language in Visual studio is C#, but many other programming languages are supported.

Visual studio is available for Windows and macOS.

Visual Studio (from 2017), has integrated support for Python, it is called "Python Support in Visual Studio".

Web: https://visualstudio.microsoft.com

Wikipedia: https://en.wikipedia.org/wiki/Microsoft_Visual_Studio

 

 

Python Integration in LabVIEW

LabVIEW is a graphical programming language well suited for hard-ware integration, taking measurements and data logging.

Go to my LabVIEW page in order to learn more about LabVIEW.

Download Python Integration in LabVIEW Examples

 

 

Python Integration in MATLAB

MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is an abbreviation for MATrix LABoratory, so it is well suited for matrix manipulation and problem solving related to Linear Algebra, Modelling, Simulation and Control applications, etc...

Go to my MATLAB page in order to learn more about MATLAB.

Download Python Integration in MATLAB Examples

Programming Resources

Below you will find more interesting Programming resources


HTML

Learn more about HTML Programming

ASP.NET

Learn ASP.NET Web Programming



LabVIEW

Learn Basic LabVIEW Programming

MATLAB

LabVIEW programming and Training



Software Engineering

Software Development and Enginnering Resources

Database Systems

Database Systems, Structured Query Language



Visual Studio/C#

Visual Studio and C# programming resources

Industrial IT

Industrial IT resources