Python

Submodules

Intro to Jupyter Notebook and Pynamics

import pynamics from pynamics.system import System from pynamics.frame import Frame import sympy system = System() pynamics.

Go to Intro to Jupyter Notebook and Pynamics

Tutorials

Course-specific Python Packages

Install additional software packages. In Windows, go to the search bar and type “anaconda”.

Go to Course-specific Python Packages

Download and Link to Python Packages

Say you want to run a python package from source using a git repository.

Go to Download and Link to Python Packages

Google Colab Documentation

Resources Introduction to Colab and Python Getting Started with Google Colab External data: Local Files, Drive, Sheets, and Cloud Storage How to Connect Google Colab with Google Drive Embedding your image in google colab markdown What is Google Colab “Colaboratory is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud.

Go to Google Colab Documentation

Installing Anaconda

Introduction Anaconda is a distribution of Python that includes the ability to manage packages using the conda package manager as well as the ability to create and manage environments, or collections of packages that work together.

Go to Installing Anaconda

Sympy Example

import sympy a = sympy.Symbol('a') b = sympy.Symbol('b') x = sympy.

Go to Sympy Example

Using Jupyter Notebook

About Jupyter Jupyter notebook is a useful browser-based IPython editor that provides inline documentation via markdown and inline plotting functionality for a one-stop-shop coding and documentation experience.

Go to Using Jupyter Notebook

Others

Advanced Data Types

There are a number of advanced data types native to Python.

Go to Advanced Data Types

Basic Data Types

A “literal” value is one that is typed into code. Think “4.

Go to Basic Data Types

Conditional Statements

Conditional Statements use the keywords if, then, and else to perform different logic depending on the statements that are evaluated.

Go to Conditional Statements

functions and arguments

Functions The structure of a function is: def my_function_1(my_variable_1,my_variable_2): result = my_variable_1+my_variable_2 return result Where my_function_1 is the function, and my_variable_1 and my_variable_2 are the “arguments”.

Go to functions and arguments

Intro to Python

One thing I really like about python is that it is based on good programming practice .

Go to Intro to Python

Loops

Introduction Loops are used to repeat code over a fixed number of cycles, or indefinitely based on logic.

Go to Loops

Operators & Operations

Basic Operators Operators in Python are just symbols that “operate” on one or more values.

Go to Operators & Operations

Packages in Python

Introduction The most important packages that I use when creating python code are those packages which make a python more Matlab-like.

Go to Packages in Python

Plotting in 3D

%matplotlib inline Visit this matplotlib tutorial on 3d Plotting Another useful reference import matplotlib.

Go to Plotting in 3D

Python Development

Now What? More Python Making your programs for others Releasing your code Licensing Collaborating Testing / Building Imports Imports should always be written at the top of the file, after any module comments and docstrings.

Go to Python Development

Updating Python Packages

There are several Python packages that are in active development for the purposes of this class.

Go to Updating Python Packages

Main Python References

The Hitchiker’s guide to Python

Important Topics for This Class

Module-Specific References

Jupyter