Introduction to Python
Dr. Yingcai Xiao
Getting started
Getting started
Tutorials:
https://www.w3schools.com/python
IDEs:
Thonny, Pycharm, Netbeans or Eclipse
Main language features
Main language features
Interpreted
Dynamically typed
Not embedded
Hello World
Hello World
Start a cmd window
mkdir phython
cd phython
notepad hello.py
Type in the following code and save
print("Hello, World!")
python hello.py
Formating
Formating
Block by indentation, not braces.
Comments: #, “”” “””
Variable name: only alpha-numeric and underscores
x, y, z = "Orange", "Banana", "Cherry“
fruits = ["apple", "banana", "cherry"]
Data Types
Data Types
https://www.w3schools.com/python/python_datatypes.asp
https://www.w3schools.com/python/python_strings_metho
ds.asp
Multiline string:
S = “”” line one
line two”””
Data Types
Data Types
thislist = ["apple", "banana", "cherry"]
print(thislist[-1]) # cherry
print(thislist[0]) # apple
Control Structures
Control Structures
if b > a:
print("b is greater than a")
i = 1
while i < 6:
print(i)
i += 1
Functions
Functions
def my_function(fname, lname):
print(fname + " " + lname)
anonymous function
lambda arguments : expression
x = lambda a : a + 10
print(x(5)) # 15
Classes/Objects
Classes/Objects
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36)
print(p1.name)
print(p1.age)
Classes/Objects
Classes/Objects
class Student(Person):
def __init__(self, fname, lname, year):
super().__init__(fname, lname)
self.graduationyear = year
x = Student("Mike", "Olsen", 2019)
Iterator /RegEx
Iterator /RegEx
mytuple = ("apple", "banana", "cherry")
myit = iter(mytuple)
print(next(myit))
print(next(myit))
print(next(myit))
https://www.w3schools.com/python/python_regex.asp
PIP
PIP
PIP is a package manager for Python packages
https://pypi.org/project/pip/
pip list
File
File
https://www.w3schools.com/python/python_file_h
andling.asp
Numerical Python
Numerical Python
https://www.w3schools.com/python/numpy/default
.asp
Numerical Python
Numerical Python
https://www.w3schools.com/python/numpy/default
.asp
Array operations
Statistics
Universal Functions
Math functions
Pandas
Pandas
https://www.w3schools.com/python/pandas
Data Analysis
Plotting
Scientific Py
Scientific Py
https://www.w3schools.com/python/scipy
Sparse Data
Spatial Data
Graph
Matlab
Interpolation
Django
Django
https://www.w3schools.com/django
Four-tier web app development framework
Matplotlib
Matplotlib
https://www.w3schools.com/python/matplotlib_intro.asp
graph plotting library for visualization
ML: Machine Learning
ML: Machine Learning
https://www.w3schools.com/python/
python_ml_getting_started.asp
MySQL
MySQL
https://www.w3schools.com/python/python_mysql_getstarted.asp
MongoDB
MongoDB
https://www.w3schools.com/python/python_mongodb_getstarted.asp

a ppt on python from Ai made for presentation but it is a failure