Welcome to AI Programming with Python

Start using AI techniques and developing skills related to programming, linear algebra, and neural networks.

Why Python Programming

Start coding with Python, drawing upon libraries and automation scripts to solve complex problems quickly.

Data Types and Operators

Control Flow

Functions

Scripting

Lab Classifying Images

In this project, learners will be testing their newly-acquired Python coding skills by using a trained image classifier. They will need to use the trained neural network to classify images of dogs (by breeds) and compare the output with the known dog breed classification. Learners will have a chance to build their own functions, use command line arguments, test the runtime of the code, create a dictionary of lists, and more.

NumPy

Learn how to use all the key tools for working with data in Python: Jupyter Notebooks, NumPy, Anaconda, Pandas, and Matplotlib.

Pandas

Matplotlib and Seaborn Part 1

Learn how to use Matplotlib to choose appropriate plots for one and two variables based on the types of data you have.

Matplotlib and Seaborn Part 2

Introduction

Learn the foundational math needed for AI success—vectors, linear transformations, and matrices—as well as the linear algebra behind neural networks.

Vectors

Linear Combination

Linear Transformation and Matrices

Vectors Lab

Linear Combination Lab

Linear Mapping Lab

Linear Algebra in Neural Networks

Introduction to Neural Networks

Gain a solid foundation in the latest trends in AI: neural networks, deep learning, and PyTorch.

Implementing Gradient Descent

Training Neural Networks

Deep Learning with PyTorch

Create Your Own Image Classifier

How Do I Continue From Here

22. Lists and Membership Operators

List and Membership Operators

There are three videos as a part of this page. Be sure to check them out along with the additional helpful reminders!


Lists!

Data structures are containers that organize and group data types together in different ways. A list is one of the most common and basic data structures in Python.

You saw here that you can create a list with square brackets. Lists can contain any mix and match of the data types you have seen so far.

list_of_random_things = [1, 3.4, 'a string', True]

This is a list of 4 elements. All ordered containers (like lists) are indexed in python using a starting index of 0. Therefore, to pull the first value from the above list, we can write:

>>> list_of_random_things[0]
1

It might seem like you can pull the last element with the following code, but this actually won’t work:

>>> list_of_random_things[len(list_of_random_things)] 
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-34-f88b03e5c60e> in <module>()
----> 1 lst[len(lst)]

IndexError: list index out of range

However, you can retrieve the last element by reducing the index by 1. Therefore, you can do the following:

>>> list_of_random_things[len(list_of_random_things) - 1] 
True

Alternatively, you can index from the end of a list by using negative values, where -1 is the last element, -2 is the second to last element and so on.

>>> list_of_random_things[-1] 
True
>>> list_of_random_things[-2] 
a string