Tag Archives: Python

AI on the Edge LESSON 4: Python Averaging Grades Homework Solution

Hey everyone, and welcome back to the AI on the Edge series!

In Lesson 3, I gave you your first real programming homework — to create a program that lets the user enter multiple grades and then calculates the average. In today’s Lesson 4, we go through the solution together step-by-step.

This lesson is all about learning how to work with lists (also called arrays), using for loops effectively, and building clean, organized code. Even though averaging grades might seem simple, these are fundamental programming skills that we will use constantly as we move forward in this class. Whether we’re averaging sensor readings, smoothing camera data, calculating confidence scores from AI models, or processing batches of information — the ability to collect data, store it, and process it is extremely important.

In the video, I walk you through a clean solution that uses a list to store all the grades, then loops through that list to calculate the total before dividing by the number of grades. You’ll also see how to display the original grades back to the user and present the final average in a nice, readable way.

I really enjoy these early lessons because this is where you start developing good programming habits. The techniques you learn here — using lists, loops, and organizing your code — will become the building blocks for much more powerful AI projects later in the series.

By the end of this lesson, you should feel much more comfortable working with lists and loops in Python. These skills are going to be used over and over again as we start reading sensors, processing camera frames, and handling data from AI models.

So if you tried the homework, awesome! If you got stuck, that’s perfectly okay — that’s exactly why we go through the solution together. Take the code, run it, and then I strongly encourage you to modify it. Try adding letter grades (A, B, C), calculate the highest and lowest grade, or make it keep running until the user wants to quit. The more you play with it, the faster you’ll learn.

You’re doing great! These early Python lessons are the foundation we need before we start combining code with real hardware and AI in the coming lessons. Keep going — we’re building something really cool here!

This is my homework solution.

 

AI on the Edge LESSON 3: Learn Python Essentials In One Session

Hey everyone, and welcome back to the AI on the Edge series!

In today’s lesson, we’re doing something really important. Since this entire class is going to be taught using Python, I wanted to make sure everyone — even complete beginners — has a solid foundation before we start attaching hardware and diving into real AI projects.

In this marathon session, I take you through all the Python essentials you’ll need for the rest of the class. We cover variables, data types, if statements, for loops, while loops, lists, getting user input, and how to organize your code in a clean, readable way. I even share my personal philosophy on keeping code simple (you’ll notice I avoid nested else statements like the plague because I like my logic clean and easy to follow).

This lesson is designed to be a complete “Python boot camp” in one video. Even if you’ve never written a line of code before, by the end of this lesson you’ll have the core skills needed to keep up with everything we’re going to build in this series. And if you’re already comfortable with Python, this is still a great refresher with my specific style and approach that we’ll be using throughout the class.

I really believe that strong programming fundamentals are the key to success in AI on the Edge. Once you’re comfortable with these basics, we can focus on the fun stuff — controlling hardware, reading sensors, processing camera images, using voice commands, and building intelligent systems.

So whether you’re brand new to programming or just need a solid review, grab a cup of coffee, settle in, and let’s spend some quality time getting you up to speed with Python. I encourage you to code along with me in the video and actually type every example. That hands-on practice is what makes it stick.

By the end of this lesson, you’ll be ready for the homework assignment, which will test everything we covered today. Once you’ve got that down, we’ll be ready to start connecting real hardware in the very next lessons.

You’ve got this! Let’s turn you into a confident Python programmer so we can go build some amazing AI projects together.

AI on the Edge LESSON 2: Raspberry Pi Operating System for Artificial Intelligence

The major challenge we face in this AI on the Edge class is getting a Raspberry Pi 5 configures where you have all the AI Models, Libraries, Modules and Methods installed, and where they all play nicely together. Often, when you add a new model, the old model becomes broken. This is because when you install something new, it often times updates the dependencies. That means it updates a library already on your system. For example, lets say you have numpy 14, working with YOLO 11. Now you install mediapipe, and it updates numpy 14 to numpy 15. This then ‘Breaks’ your YOLO, as it wanted a different version of numpy.  Likely you will get frustrated and quit before you get the dependency problems solved. In order to get around this, you can use a special education version of the Bookworm OS, which has all the needed libraries installed already and working nicely with each other. The video above shows you how to install this OS. Once you do, no not update it, do not upgrade it, do not touch it. Use it to develop your programs and projects for this class. If you want to do something else with your pi, have a separate SD card.

PyQt Essentials for Absolute Beginners

In this Video Lesson we show you how to create a Graphical User Interface to allow you to interact with your python program and hardware projects. The GUI can have buttons, slider bars, radio buttons, drop down menus, and many more widgets. In this lesson we show you how to install the package, and step-by-step instructions on how to use it. For your convenience, here is the code we developed in the lesson.

 

Sending Data Over WiFi Between Raspberry Pi Pico W and Your PC

In this video lesson we show how we can send and receive data between the Raspberry Pi Pico W, and your PC. We will be running python on the PC, and we will exchange data using the UDP protocol. UDP is simple, and a very reliable way to send data packets back and forth. In this example, we will be demonstrating a simple Client Server relationship between the Pi Pico and PC using UDP over WiFi.

For your convenience, this is the “Server” software you will run on the Pi Pico.

Notice that the above code wants to load a “secrets” file that contain your WiFi name, and password

You should edit the code below with your WiFi username and your password, and then save the file in the Pi Pico lib folder, with the name secrets.py (don’t forget the .py)

Now, on the PC side, you will run your client, which will be run in Python. Here is the client software: