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

04. Solution: Conditional Statements

Quiz Solution: Which Prize

Here’s my solution for this quiz!

points = 174

if points <= 50:
    result = "Congratulations! You won a wooden rabbit!"
elif points <= 150:
    result = "Oh dear, no prize this time."
elif points <= 180:
    result = "Congratulations! You won a wafer-thin mint!"
else:
    result = "Congratulations! You won a penguin!"

print(result)

Output:

Congratulations! You won a wafer-thin mint!

We use <= instead of the < operator, since it was stated that the upper bound is inclusive. Notice that in each condition, we check if points is in a prize bracket by checking if points is less than or equal to the upper bound; we didn’t have to check if it was greater than the lower bound. Let’s see why this is the case.

  • When points = 174, it first checks if points <= 50, which evaluates to False. We don’t have to check if it is also greater than 0, since it is stated in the problem that points will always be a positive integer up to 200.

  • Since the first condition evaluates to False, it moves on to check the next condition, points <= 150We don’t need to check if it is also greater than 50 here! We already know this is the case because the first condition has to have evaluated to False in order to get to this point. If we know points <= 50 is False, then points > 50 must be True!

  • Finally, we check if points <= 180, which evaluates to True. We now know that points is in the 151 – 180 bracket.

  • The last prize bracket, 181-200, is caught in the else clause, since there is no other possible value of the prize after checking the previous conditions.