1 of 27

PROGRAM AI-1

Revision

(Chapter 1 - 13)

2 of 27

  • C1: Introduction to Python Programming ✅
  • C2: Introduction to Jupyter Notebook (via Google Colab) ✅
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

Introductionand Setup

3 of 27

Python Programming

  • Popular programming language
  • Widely used for data analysis
  • Compared to other language
    • Code: Use new line instead of ;
    • Scope: Use indentation instead of {}

4 of 27

Jupyter Notebook(Google Colab)

File extension: .ipynb

5 of 27

Data type and manipulation

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator ✅
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

6 of 27

Variable

Cannot Do ❌ :

  • Start with number (e.g: 10name)
  • Contain space (e.g: user name)
  • Using reserved words

7 of 27

Variable and Data types

Example

Data type(variable)

“Hello World”

string (str)

999

integer (int)

3.145

real number (float)

False

boolean (bool)

[“tiger”, “cat”, “dog”]

list (list)

(“tiger”, “cat”, “dog”)

tuple (tuple)

{“animal”: “tiger”, “type”: “carnivore”}

dictionary (dict)

8 of 27

Operator and operands

Operator

Operation

Example

+

Addition

x + y

-

Subtraction

x - y

*

Multiplication

x * y

/

Division

x / y

**

Power(Exponential)

x ** y

%

Remainder

x % y

  • The table below show the example of mathematical operators with operands x and y:
  • Parentheses > Exponential > Multiplication/Division > Addition/Subtraction

9 of 27

Basic Syntax

  • print()
  • input()
  • str()
  • int()
  • float()
  • round()

10 of 27

Data Structure

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List ✅
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary ✅
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

11 of 27

List vs Dictionary

Differences

List

Dictionary

Sequence

ordered

unordered

Access item

index

key

Symbol

[]

{}

List

Dictionary

12 of 27

Logic and Selection

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement ✅
  • C6: Loop ✅
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

13 of 27

Conditional Statement

if state == “Hungry” :

Eat()

condition

indentation

Code to execute

Comparison ==, Assign =

    • If-else Statement
    • If-elif-else Statement
    • Combining Conditions in Statement

14 of 27

For Loop

for item in sequence:

Block of codes to execute

[1, 2, 3, 4, 5]

First item > Second item > … > Last item

print(item)

while condition:

Block of codes to execute

While Loop

When

it is true

15 of 27

Define and use

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function ✅
  • C9: Package ✅
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

16 of 27

def function_name(parameters):

Block of codes to execute

return(optional)

Function

Define/Create

function_name(arguments)

Call

17 of 27

  • To use python package,

We need to install and import.

  • There are two types of package:
    • Built-in package: No need to install.
    • External package : Need to install.

Package

18 of 27

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy ✅
  • C11: Descriptive Statistics
  • C12: PrettyTable ✅
  • C13: Data Visualization using Matplotlib

Useful Packages

Revision (Basic of Python & Packages)

19 of 27

NumPy array

  • Advantages:
    • Faster and easier dealing with numbers
    • Can use for mathematical operations

    • Widely used for multidimensional array
    • Filter the data

20 of 27

PrettyTable

Easy to understand

21 of 27

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics ✅
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib

Revision (Basic of Python & Packages)

Statistical concept

22 of 27

Descriptive Statistics

  • Mean - the average.

  • Median - the midpoint value in a sorted, ascending or descending, list of numbers that divides into two halves.

23 of 27

Descriptive Statistics

  • Mode - the value that appears the most in a dataset.

24 of 27

  • C1: Introduction to Python Programming
  • C2: Introduction to Jupyter Notebook (via Google Colab)
  • C3: Variable & Operator
  • C4: List
  • C5: Conditional Statement
  • C6: Loop
  • C7: Dictionary
  • C8: Function
  • C9: Package
  • C10: NumPy
  • C11: Descriptive Statistics
  • C12: PrettyTable
  • C13: Data Visualization using Matplotlib ✅

Revision (Basic of Python & Packages)

Graph figure

25 of 27

Data Visualization using Matplotlib

  • More understandable (colors and patterns)
  • Identify patterns and trends in large datasets.
  • Graphs and charts are used
  • Matplotlib built on top of NumPy

26 of 27

Components of Figure

Title

x-axis

y-axis

Label

Graphs

Legend

27 of 27

All the best for Quiz 1