ISE233 Lecture 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Operational Data Analysis for

Industrial Systems
(Lecture 4)
Why Python ?
• Open source, high level script language
✓ Rich libraries
✓ Easy to learn

• In particular good for ISE professionals, such as Numpy, scipy, statistics, optimization,
sklearn, computation libraries

• For data scientist/machine learning jobs, Python is very useful

• Much more, check Wikipedia


Synopsis
• Download and install Python
• Basic Python Operations and Concepts
✓ Arithmetic
✓ Python variables and types
✓ Functions
✓ Loops
Download and install Python
• Python Anaconda distribution includes the most popular analytics packages. You can download
and install Python Anaconda distribution v 5.1 for Python 3.6 from
https://www.anaconda.com/download

• Check if Python environment was installed successfully using


✓ import sys
✓ print('Python: {}'.format(sys.version))
Install/Import Python Packages
• Install packages
✓ Installer – pip: recommended for Python package installation from PyPI

• Import packages
✓ Import package after installation so that functions in the package can used

• Popular analytics Python packages: Numpy, pandas, Matplotlib, SciPy, sklearn


Basic Python Operations and Concepts - Operator, Variable
• Arithmetic – operators: +, –, /, *, **, %
• Python variables
✓ Think about a variable as data, but its content can be changed. So, think about it as
dynamic data
✓ Variable has a name. It allows you to refer to a value with a name.
✓ Python is case sensitive
• Common Python variable types
✓ float
✓ integer
✓ string
✓ boolean
✓ different types have different operation rules
Basic Python Operations and Concepts - Function
• Think about the function as a black-box: input some data, output another set of data

• In order to define a function, we need to use a reserved word "def“

• A function also has body, which is indented

• In order for a function to run, it must be called into action. A function will not run by itself
Basic Python Operations and Concepts - Loop
• For Loop
✓ used to iterate over elements of a sequence, it is often used when you have a piece of
code which you want to repeat "n" number of time.
✓ It works like this: " for all elements in a list, do this”
• While Loop
✓ The while loop tells the computer to do something as long as the condition is met
✓ it's construct consists of a block of code and a condition.
✓ It works like this: " while this is true, do this "

You might also like