1 of 19

ME 4990�Introduction to CS

Introduction to Python

2 of 19

Outline

  • Introduction
  • Basic Python Grammar
    • AD Chapter 2
    • AD Chapter 3

3 of 19

Course Introduction

  • Mission statement
    • “Basic” Python Programming
    • Introduction to Data Science
    • Jobs?

  • About me
    • Yizhe Chang
    • Major in ME, doing things in CS, learned Python at age of 30
    • Interested in, not so sure, er EE?
    • The course I feel cool: HMC E85

4 of 19

Arrangement

  • 4 Modules

    • Module 1: Python Programming
    • Module 2: Classifier with Bayes (Wired Logic, Hard)
    • Module 3: “Modern” learning technique
    • Module 4: Seminar – Going deep

5 of 19

HW

  • 6 HWs
    • 2 for Module 1
    • 2 for Module 2
    • 2 for Module 3
    • 0 for Module 4 (maybe a bonus one?)

  • Mid-term
    • Module 1 and module 2 (module 2 most)

  • Final Project
    • A machine learning project

6 of 19

How to find me

  • Zoom links on blackboard (cannot put on public, sorry)

  • Monday: 1:30-2:15pm (PDT)
  • Tuesday and Wednesday: 4:30pm-6:30pm (PDT) (Last 45 min by email appointment)
  • Open-door policy (just email me, I am at an unspecific place in Pomona, CA)

7 of 19

Pre-req

  • None specified. But you want to drop if you hate:

  • ME1101: Computation for ME students
  • MAT2240: Linear Algebra

8 of 19

Textbook: thank online legit free version

  • (Referred as AD in course) �Think Python: How to Think Like a Computer Scientist by Allen B. Downey�O' Reilly Press, 2015�(Online)(Amazon)(O'Reilly)
  • (Referred as DB in course) �Bayesian Reasoning and Machine Learning by David Barber�Cambridge University Press, 2012�(Online)(Cambridge)
  • (Referred as HTF in course)�The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition by Trevor Hastie, Robert Tibshirani, Jerome Friedman�Springer, 2009�(Online)(Amazon)(Springer)�

9 of 19

Python

  • Syntax: almost non-exist compared to C
  • Grammar and function: almost same as MATLAB
  • Free, https://www.python.org/
  • Bad: indention

  • Why Python so popular: I don’t know…

10 of 19

Python Operator (AD chapter 1)

11 of 19

Python Operator

12 of 19

Python Operator

13 of 19

Python Operator

14 of 19

Python Operator

15 of 19

Looks… easy

  • a=40+2
  • b=43-1
  • c=6*7
  • d=84/2
  • e=6**2+6

  • Congrat!

16 of 19

Variable (AD chapter 2)

  • You can create variable of almost any name

  • Here is a list of names you cannot use:

17 of 19

String

  • String operation is never as simple as python:
  • Use single quote (‘’), although some version of python also allows double quote (“”)

18 of 19

Comment

  • Use sharp sign (#) for comment

19 of 19

Installing Python: nightmare

  • Infinite development environment
  • VSCode: (simple but modern)

  • Online compiler: