Introduction to Python Programming for AI
Introduction to Python Programming for AI
AI Thinking
Introduction to Python Programming for AI
Disclaimer
Miami Dade College has adapted the content on the subsequent slides from the
AI for Current Workforce program, which is part of
Intel® Digital Readiness Programs.
Topics
1. What is Python?
2. Getting started with Python using Google Colab
3. Some Python exercises
3
What is Python?
What is Python?
• General purpose coding language
• Easy to learn and use
• Free!
5
Why are we using Python?
• Easy to read
• Huge repository of Libraries to use
• Flexible
• Quick to see results
6
Applications of Python
• Data Science
• Business
• Games
• Artificial Intelligence
7
Getting Started
Applications
• Jupyter Notebook
Jupyter Notebook
• Anaconda
• repl.it
• Google Colab
Google Colab
8
Go to Google Colab
Sign In
Link here
9
Go to the Upload tab
10
Upload File
• Locate [Notebook - student] Module 3 (Introduction to Python).ipynb
• Let’s Begin!
11
Refer to your Notebook in Google Colab
12
Python Comments
• Use the # symbol
• Everything after # in the same line will be a comment
13
Python Data Types
• Variables are “containers” for storing data values
• No need to declare variables in Python
• But an assigned value has a type
14
Numbers
• Syntax is similar to other programming languages
• Parentheses used for grouping, order or precedence
15
Lists
• Are an ordered sequence of items
• Can contain different data types
16
Strings
• Strings are a sequence of characters
• Python has functionality to manipulate strings
17
Data manipulation
• String concatenation
• Indexing
• Slicing
18
Tuples
• Are an ordered sequence of items
• Cannot be modified unlike Lists
19
Dictionary
• Unordered collection of key-value pairs
• Like a real dictionary, you look up a key to get its value
• Keys must be unique, values do not
20
Type Conversion
• Changing of one data type to another
• Implicit
• Explicit
21
Reflections
• What are the different data types we’ve seen and how are
they different from each other?
• Let’s discuss!
22
Flow Control
• If-else statements & loops
• Requires a condition
• Think of a traffic light, codes are only work when its “green”
23
Python Functions
• Looks neater
• Is a block of code
• Facilitates code reusability
24
Python Modules
• A File containing Python statements and definitions file.py
• Code manageability
• Facilitates code reusability
25
Python Packages
• Organized group of modules
• Works like a folder containing multiple documents
• Must contain an initialization file init.py
26
Let’s play Kahoot!
Go to the link.
2
27
7
Let’s do the exercises
Things to do
• Attempt the Exercises
• Can you tackle the bonus exercise?
• Feel free to use the Internet to look for
resources to complete the exercises
28
Reflections
• In what way would flow control be useful?
• Let’s discuss!
29
Any last words?
30