Python for AI - Full Beginner Course

Dave Ebbelaar · 9 months ago

At a glance

Length
5 hr 16 min
Channel
Dave Ebbelaar
Video from
Oct 2025
Rating
⭐⭐ Great video · 2/2
Best for
Beginners with no coding experience wanting to start Python for AI

What this video answers

  • Do I need any prior programming experience?
  • What tools do I need to install before starting?
  • Will this course teach me machine learning algorithms?
  • How much time should I dedicate to complete it?
  • Will I be able to build real AI applications after this?

What This Python for AI Course Covers

Dave Ebbelaar's "Python for AI - Full Beginner Course" is a comprehensive introduction designed to take complete beginners from zero Python knowledge to building real artificial intelligence applications. The video spans over four hours and walks through everything from environment setup to object-oriented programming and version control, structured in a way that prioritizes practical hands-on learning over theory.

The course positions itself as one of the fastest beginner-friendly pathways into Python specifically for AI development, rather than a general programming course. It assumes no prior coding experience and includes setup guides for both Windows and Mac, making it accessible regardless of your operating system.

Key Moments

Key Strengths and Learning Outcomes

  • Complete setup guidance covering Python installation, VS Code configuration, virtual environments, and package management—removing common friction points for newcomers
  • Structured progression from syntax fundamentals (variables, data types, operators) through control flow and functions to advanced concepts like classes and object-oriented programming
  • Practical focus on real-world tools including working with APIs, reading and saving data files, organizing code into modules, and version control via Git and GitHub
  • Hands-on exposure to popular AI and data libraries like Pandas and Matplotlib, plus Jupyter notebooks for interactive Python development
  • Error handling and debugging instruction integrated throughout, treating mistakes as a normal part of learning
  • Project-oriented approach emphasizing code organization and file structure rather than isolated code snippets
Featured image for the guide to Python for AI - Full Beginner Course by Dave Ebbelaar

Who Should Enroll in This Course

This tutorial is best suited for absolute beginners interested in AI development who want a structured, fast-track introduction. If you're coming from non-technical backgrounds or have no programming experience, the video's attention to environment setup and syntax basics will get you oriented before jumping into AI-specific concepts. The course works well if you learn better by watching someone set up projects step-by-step rather than reading documentation alone.

It's less suitable if you already know Python basics and are looking to specialize in advanced machine learning—you'd skip much of the foundational material. However, if you've learned Python elsewhere but want a refresher on best practices like virtual environments, file organization, and Git workflows before tackling AI projects, selective chapters would still add value.

Frequently Asked Questions About Learning Python for AI

Do I need any prior programming experience?

No. The video starts with Python installation and syntax fundamentals, assuming no background in coding. It covers what programming is conceptually before diving into language-specific details.

What tools do I need to install before starting?

You'll need Python itself, VS Code (a code editor), and the ability to use a command line or terminal. The video includes platform-specific installation walkthroughs for both, plus instructions for useful VS Code extensions.

Will this course teach me machine learning algorithms?

Not directly. The course teaches Python fundamentals and introduces data handling with libraries like Pandas and visualization with Matplotlib, which are prerequisites for machine learning. It's designed to prepare you for learning AI and machine learning, not to teach those topics themselves.

How much time should I dedicate to complete it?

The video runs over four hours, but that's viewing time. Actual learning time depends on how much you pause to practice. Plan to spend additional hours writing code alongside each section to solidify the concepts.

Will I be able to build real AI applications after this?

You'll have the Python foundation and familiarity with key libraries needed for AI work. However, this course is the foundation—building production AI applications requires additional learning in machine learning frameworks and domain expertise, which typically comes next.

A still from the video Python for AI - Full Beginner Course by Dave Ebbelaar
Explore more artificial intelligence

Gear & products featured here

As an Amazon Associate we earn from qualifying purchases.

See the BEST NEW products on Amazon!

Key Terms

Virtual environment
An isolated folder where your project's Python packages live separately from your system Python, preventing conflicts between projects.
Pip
Python's package installer—the tool that downloads and installs libraries like Pandas or Requests that extend Python's capabilities.
API
A way for one program to request data or services from another program over the internet, commonly used in AI applications.
Classes
A way to organize and bundle data with functions that operate on that data, forming the foundation of object-oriented programming.
Git
A version control system that tracks changes to your code files, letting you save different versions and collaborate with others.
Jupyter
An interactive notebook environment where you write and run Python code in cells, useful for exploration and data work.

Sources: Virtual environment · Pip · API · Classes · Git · Jupyter — definitions cross-referenced with Wikipedia

Justin’s Take

This video serves a genuine need for people who want to learn Python specifically for AI without drowning in generic "learn to code" material that meanders into unrelated territory. The pacing respects that beginners need both conceptual understanding and hands-on repetition, and the structured progression from setup through libraries to real-world patterns mirrors how professional developers actually work.

The standout strength is how thoroughly the video handles the environment and setup phase—something many tutorials gloss over, leaving beginners confused before they write their first line. If you're starting from zero and want a guided, practical path into Python for AI, this course genuinely delivers. Absolutely worth your time.

Great video · 2 out of 2

Justin
Justin

I started Helicopterstour.com because I genuinely believe there’s no better way to see the world than from the sky. I used to work on the Pride of America cruise ship in Hawaii, helping guests book shore excursions all over the islands. Two Vacation Hero Awards 2,000+ Guests/Week Pride of America · NCL Hawaii Shore Excursions 1000+ Tours Reviewed

Video by Dave Ebbelaar on YouTube. If you enjoyed it, please subscribe to their channel and show your support for the great video.

Description

Learn Python from scratch and start building real AI applications. This is the fastest, beginner-friendly course Python for AI development.

📕 Course Handbook: https://go.datalumina.com/cm5P6b6
📥 Course Resources: https://go.datalumina.com/M2YfRW3
👊🏻 Let's connect on IG: https://www.instagram.com/daveebbelaar/

🎙️ Try Glaido, the #1 dictation tool for developers:
https://get.glaido.com/dave

⏱️ Timestamps
00:00:00 Introduction: Learn Python for AI
00:01:42 Course Overview & Structure
00:03:58 Installing Python
00:04:05 Installing Python on Windows
00:05:10 Installing Python on Mac
00:06:53 Installing VS Code
00:08:34 Setting Up VS Code (Extensions)
00:12:08 Customizing VS Code
00:13:31 Creating Your First Project
00:16:18 Creating a VS Code Workspace
00:18:02 Your First Python File (hello.py)
00:20:10 Running Python Code
00:26:23 Exercise & Recap
00:29:26 Course Resources & Community
00:31:07 Understanding Python Environments
00:33:15 Understanding Python Packages & Pip
00:34:00 Creating Virtual Environments (venv)
00:37:34 A Note on Anaconda
00:38:32 Installing Python Packages (pip install)
00:42:51 Using Python Packages (Import)
00:44:29 Interactive Python with Jupyter
00:48:30 Full Setup Recap & Exercise
00:51:36 What is Programming?
00:55:19 Understanding Python Syntax & PEP8
00:58:00 Understanding & Debugging Errors
01:01:33 Variables
01:06:03 Comments
01:09:48 Data Types Introduction
01:10:12 Numbers (Integers & Floats)
01:13:36 Strings
01:19:39 String Formatting (F strings)
01:21:49 String Methods
01:26:35 Booleans
01:31:02 Operators (Arithmetic, Comparison, Logical)
01:39:19 Shortcut Assignments (+=)
01:40:24 Control Flow Introduction
01:41:35 Conditional Statements (if, elif, else)
01:47:11 Loops (For Loops & range())
01:52:13 Data Structures Introduction
01:53:32 Lists
01:59:10 Dictionaries
02:00:23 Tuples
02:01:37 Sets
02:05:51 Functions (Defining & Calling)
02:15:02 Function Parameters & Arguments
02:22:42 Global vs Local Variable Scope
02:28:50 Returning Values from Functions
02:37:37 External Tools (Modules, Packages)
02:40:48 Importing Modules & Built ins
02:47:56 Import Methods Summary
02:48:48 Installing Packages & requirements.txt
02:56:04 Working with APIs (Requests Example)
03:06:20 Working with Data Example (Pandas & Matplotlib)
03:10:46 Reading & Saving Data Files
03:14:50 Practical Python Introduction
03:16:47 Project Structure & Organization
03:22:02 Understanding File Paths
03:26:37 Working with Different File Types
03:34:05 Organizing Code into Modules
03:39:39 Error Handling (Try/Except)
03:45:31 Introduction to Classes (OOP)
03:49:09 Creating Your First Class (__init__, self)
03:57:04 Class Attributes vs Instances
04:00:10 Class Methods
04:05:23 Class Inheritance
04:07:32 When to Use Classes vs Functions
04:09:44 Introduction to Git & GitHub
04:12:31 Git Fundamentals
04:15:41 Installing Git
04:16:46 Basic Git Workflow
04:18:41 GitHub Account Setup & Authentication
04:22:37 Cloning GitHub Repositories
04:28:12 Creating Repositories & .gitignore
04:36:12 Using Git with VS Code UI
04:44:05 Environment Variables & Secrets (.env)
04:52:13 Using python dotenv Package
04:55:03 Introduction to Ruff (Linter & Formatter)
04:56:13 Setting Up Ruff in VS Code
04:57:23 Ruff in Action
05:01:10 Introduction to Uv (Modern Package Manager)
05:02:07 Installing Uv
05:02:30 Using Uv (uv init, add, sync)
05:09:01 Complete Python Project Workflow Exercise
05:11:13 Course Wrap up & What's Next

👋🏻 About Me
Hi! I'm Dave, AI Engineer and founder of Datalumina®. On this channel, I share practical tutorials that teach developers how to build production-ready AI systems that actually work in the real world. Beyond these tutorials, I also help people start successful freelancing careers. Check out the links above to learn more!

Video transcript Accessibility

A full written transcript of this video, provided for accessibility. Select any timestamp to jump the video to that moment.

If you want to learn the Python programming language specifically to build AI applications, then this video is for you. We're going from absolute beginner to writing real Python code for AI applications all in one video. And right now, Python is the language for artificial intelligence. So whether you

want to build your own AI apps, get into data science, or simply become more valuable in your career, this is one of the most in demand skills you can learn right now. And now there are already a ton of learned Python tutorials and courses out there, right? You're probably wondering which one should I

follow and why should I watch this video? Well, most of the videos out there actually waste your time on a lot of stuff that you actually don't need to know if you want to use Python specifically for AI. So, this video is different. We'll start from the basics and I'll make sure to explain everything

step by step so you can follow along. Then, I'll teach you all the core concepts you need to understand in order to learn Python fast. We'll build up in complexity, work with data, and create reports. And as a final exercise, you're going to build your own AI chat assistant that can chat with your data.

My name is Dave Ealar. I'm the founder of Datal Lumina, an AI development company where we built custom AI solutions for clients across many industries now. I've been using Python almost every single day for over a decade, and I already taught this language to more than 35,000 students

worldwide. So, if you're looking to learn Python from a professor who only teaches, this is not the course for you. Everything that we'll be doing in this course is practical, battle tested, and it's based on real work in the AI field. The stuff companies and clients are paying for right now. And look, it

doesn't matter what your background is. You're never too young, too old, or too late to start. If you can follow simple explanations and have a bit of curiosity, that's important. You can do this. So, grab a coffee and take out your notes. This is Python for AAI, the course I wish I had when I started.

Let's dive in. All right, so let's get started. I am super excited to go through this entire course with you and to teach you everything that you need to know about Python to build AI applications. Before getting started and installing Python, let me give you a quick overview in 30 seconds how to get

the most out of this course. What you are looking at right now is the handbook which I will make available for you link in the description. It's hosted under python.dataluminina.com. All of the other information, links, codelocks that you need will be in here. So use that to your advantage. Now,

whenever I go too fast, you can go back here, find more information. And whenever you feel like I'm going too slow, use the chapters below this video to skip ahead or use the speed controls below this video to increase the speed of the video. And now, what's going to make this course different from a lot of

other Python courses out there beyond just the focus on AI. In the beginning, we're going to spend a lot of time on setting up a professional work environment for you. You see, most Python tutorials and courses go through the Python setup and then they immediately jump into writing out

isolated Python code examples. But what I found over the years teaching thousands of students this language is that in the beginning, writing the code itself isn't the hardest. And especially nowadays with AI, you can literally ask JPT to come up with anything and you can plug it into your code editor. What you

need to focus on in the beginning is having a solid understanding of the tools you use, how to set up your environment, how to manage package and dependencies and how you can create projects so that whenever you go out in the real world beyond this course and you want to build something or follow a

course or tutorial, you know exactly what it is that you need to do and you'll have a professional coding setup exactly the same as what I am using right now and what you would actually use when you get a job and work with Python in the real world. So just know that we're going to spend quite some

time there in the beginning. That's the whole getting started chapter and it's there in the beginning for a reason. You don't want to skip this if you're not familiar with these concepts. So, we'll get into all of the installations, setups, and configurations that you need in order to work professionally with

Python. Then, in the Python basics, that's where we actually get into the programming language. And now, even if you already have some coding skills or you're coming from a different programming language, I still highly recommend to go through this entire getting started chapter with me because

I will show you the exact setup that I am using right now so that if you follow through with the course, everything that you see will be exactly the same on my screen as well as on your screen. All right, so let's get started. The first thing that we are going to do is install Python on your machine. So following the

handbook, I am here in the section installing Python to get it up and running on your computer. So, I'm first going to walk through the Windows setup. If you're on Mac, you can use the timestamps below to skip ahead. So, the first thing that you need to do is you can go to python.org/d downloads or

follow the link over here. Then you will find this page where you can simply click on download python. And then once that's uh completely done, you can doubleclick on it to start the installer. Now, here is a very important thing. When you go through the installer, you should check the

following box. When it asks, should you add Python to the path? You should check mark that. It will look somewhat like this. So, you can see it over here. Let me add a little bit smaller for you. Now, this is an older version of Python, but the setup will look something like this. And you should add Python to your

path. Then, you can just follow through with the installer. Do not customize anything unless you know what you're doing. All right. And that's it for the quick installation. Super easy to follow. So now next in this video I will show you how to do this on Mac but you're on Windows. So make sure to skip

to the next chapter where we're going to install your code editor. All right. So now I'll show you how you can install Python if you are on Mac. And the first thing that we need to check here is check whether Python is maybe already installed on your system because for a lot of Mac systems this is already the

case. So what we are going to do is we're going to open up the terminal. And don't worry if you've never used the terminal. We just use it to type in a command and it's not that scary. So what we can do is we can open up Spotlight. And you can do that by hitting command and spacebar. Then this will show up and

you can type in terminal. So if I open that up, you'll see this console coming up over here. This is a terminal where we can run commands. And all you need to do right now is come over here to the documentation and you should type in Python 3 space- version. So you can type it out or you can copy paste it like I

do over here. Come to the terminal and then I'm going to paste that in with command V. And what I can now do is I can hit enter. Now you can see on my Mac it is already installed because it's showing me a Python version meaning it's installed. If you also see a version over here that also means Python is

installed. If you get an error over here mentioning like look Python is not available or it's not recognized then you still need to install Python and you can continue with the rest of the instructions in here. So in case you do need to install it you can scroll down over here on this install Mac page and

you can go to python.org/d downloads which we have open over here. You can click the big download button. It doesn't matter if it's a different version. If you watch this in the future, it will be different. So, you click the download button and then over here it will start to download. So, then

while you wait for that to finish, you can go to your download folders. Simply doubleclick on it and install Python like any other app. All right. Congratulations on installing Python on your machine. Now, the next step is to install an application that actually allows us to work with the Python

programming language. So, we are going to install my favorite code editor to work with the Python programming language, and that is Visual Studio Code. And that is really all you need. I've been using this application for the past 5 years already. I love it. It's completely free. It's super extensible,

and it's really it got it's got everything that you need to professionally work with the Python programming language. And nowadays, there are, of course, a lot of AI assisted code editors out there. Cursor being one of the most popular ones right now. The good thing is that everything

that you do in setup within Visual Studio Code can also be done exactly the same and imported within Cursor because cursor is built on top of VS Code. So let's get into how to set up Visual Studio Code. So I come over here to the install VS Code tab and again depending on whether you're on Windows or Mac OS,

it's a little bit different, but you can just go to the website and this big download button over here, it will be dynamic for the operating system that you're that you're on. So for me, it will say Mac. for you. If you're on Windows, it will say Windows. So again, download it. It will go to your download

folder. Click on it and follow the installation in there. One more time. It's important that you add it to your path on Windows. And then you just click install, finish when done. Process is exactly the same for Mac OS. You can keep it in your doc. There might be some security questions that pop up where you

need to give it permission. So just follow that. It's completely safe. The application is for Microsoft. And then we can go and verify the installation. So what we can do right now is we're going to open it. And there we go. So this is the first screen that I see right now with versions updates, a

welcome screen, and now since Visual Studio Code is so extensible and it it can work with a lot of programming languages out of the box, there's not much there. So, what we're going to do right now is I'm going to share my exact setup with all the extensions and settings that I use to work on all of my

Python projects that I've been doing for the past 5 years. This is really a professionalgrade environment that we're going to set up. And this is so so crucial to spend a little bit of time here to understand this tool because what you'll find on this journey of learning Python is that actually the act

of writing code, writing out the like line by line sentences and the characters like you will quickly get a hang of that and AI can work really well with that. AI can help you as well, but you need to be able to know where to find it, how to set it up, how to create a new project, how to add new things to

it, how to run code, how to debug code. So, that's also going to be a a big difference between a lot of the other Python tutorials and courses that you'll find out there. And I know that in the beginning when I was learning Python, this was so annoying to me where always, yeah, I would get it on like a single

file. I could follow a tutorial, but then when I was on my own project, things looked different and I just didn't have the full system and it just didn't understand the full process. So that's what we're going to spend some time on right now. Okay. And the first thing that we're going to do is we're

going to install the Python extension. So I can click on the link over here to see where this is going. But we can also do this directly from Visual Studio Code. So what I'm going to do is we're going to the extensions tab and then we're going to search for Python. So let me walk you through that. Here is Visual

Studio Code completely empty. You can see the extensions over here. So, it's this little icon. There's also a keyboard shortcut to it. And you can see it's already recommending something to me. Python over here. But in case this is not there for you, you can type in Python. And then it should show you

exactly what's over here. Python. It should be from Microsoft. You see the blue check mark over here. You can click on it or directly install here or over here. So what this is going to do, this is going to behind the scenes install the Python extension so that when we work with Python files, our editor, our

code editor can recognize it. So this is an essential extension that we need. Okay, so that was the Python extension and now we're going to change a quick setting. We're going to use this later. Don't worry about it for now. All you need to do is go to the settings of Visual Studio Code and you should copy

paste this or search for this. So Python terminal execute in file directory. This is really useful for later down the line. So I can come in here. I go to settings. And then you can search for this. And you want to make sure that this is checked on a fresh new install. It's like this. And you want to click

this. And that's it. You can just X out of it. It will automatically save. So this will make sure that later when we're going to execute Python files, the editor will execute the file from the directory instead of the workspace route. So when we're going to reference files, it will be a lot easier. All

right. Then next, there are two more extensions that I recommend to install. The first one is pylance and the other one is Jupiter. So let's start with P lens first. We do exactly the same process. We come in here. We search for pilance. We see it pop up over here also from Microsoft. And you can see it's

it's actually already installed by installing Python. But you can double check this. So make sure that if you go to Pilance it it if it says install you should click it. And then we go to Jupiter which is something we are going to heavily use throughout this course but I will show that later. For now, we

can just click install and then we should be good. This takes a couple of seconds. Now, coming back to the instructions over here. What we're going to do right now is we're going to customize the code editor. And this is completely optional. This is not going to change anything about how the code

editor works, but I like to set up uh my environment in a specific way. So, for the past years, I've been using this uh theme and I really like it, the Atom one dark. So, let me show you how to install that and what that looks like. And you can also search for other teams that you

like. So, this is really just like the coloring, the fonts. You'll see it in a bit. So, I can search for Atom one dark team. Hit install. Trust publisher and install. There we go. And it automatically right now it already sets the coloring. You saw it, right? So, yeah, you can see right over here it now

asked, do you want dark modern or Adam one dark? So, I set this over here. You can also click on set the color team. So that's now installed. You can also at any point come all the way to the bottom over here where you see the little gear icon and you can see themes over here and there you can see the color theme

and the file icon. So if I click on this the color theme you can see everything that is currently installed. So if you for example let's click on the Kimi dark you can see this is a very different look to what we had right. So this is for you a way to go through it and to pick a theme that you like. All right.

Now, there's one more setting, the three indentation, but we'll actually get back to that in a couple of minutes because then I can actually show you what it does. So, for now, we are going to go to the next section, and that is creating projects. One of the most important things in the beginning to fully

understand because this is really the point where look, you see examples online, you see me go through this tutorial, but now you're in the real world and you have an idea, you want to try some. Where do you start? Right? We have Python installed. We have a code editor, but how does it work? How where

are the projects? So, let's set that up right now. So, what I recommend you to do is creating a folder somewhere on your computer. Doesn't matter if it's in your documents, in your home directory, any type of place where we are going to store all of our Python projects. So, for the sake of demonstration, I'm going

to create one on our data luminina drive over here. So, I'm going to call it Python projects. All right. And now what I want you to do next is inside this folder. So this will be the master folder. And in here we can do we can create all kinds of folders for all the projects. So first we're going to create

a folder for this course and we're going to call it Python for AI. But whenever you have another ID you want to try something else I invite you to do that in that same folder and follow a similar structure and a similar setup so that you work very organized and you always know where all of your Python projects

are. Now for the main folder, it doesn't really matter what type of naming convention you use, whether you use capital letters or not. But for the project folders itself, I recommend to use all lowercase and dashes. And why this is the case, this is actually called kebab case. And this is going to

match how projects are going to appear on GitHub. This is something we'll cover later. But this is just a best practice that I always do and I recommend you to do as well. So what it then looks like if I come in here Python projects I'm going to create a new folder and I'm going to plug in Python for AI all

lowerase and dashes using the kebab case. So now we have that created. What we can do right now is now from Visual Studio Code we can open up this folder. So let me come back over here. This is what your Visual Studio Code should look like right now. If you go over here to the explorer. So before we were

installing all of the extensions. Now we can go to the explorer and you can see this is empty. You have not opened a folder yet. So we can click on that click on open a folder and then we go to the place where we just created our Python projects and then Python 4AI. So depending whether you're on Mac, Windows

is a little bit different but make sure to navigate through the explorer or the finder to this folder. And then what you can do right here is you can click on open. And now what you can see is now this folder is opening. And the first time you do this, Visual Studio Code will ask, do you trust the outers of

this file? We created it. So yes, should be good. Okay. So now we have this empty screen over here. And now there's one more important step that you need to do for every project that a lot of beginners forget. And that is creating a workspace in Visual Studio Code. Because what we do right now, we open up a

folder and now we need to save that folder and everything in there as a workspace. A workspace is Visual Studios Code way of defining projects. And why we want to do that is in this way we create a single file that we can doubleclick it will open and everything will be there. So when you're working on

something, you hit X, you shut down your computer, you restart it, you can doubleclick on one file and everything will be there exactly how you left it. That's what the workspace is about. It's like a bookmark. It remembers everything. So now what you want to do is you want to save the workspace. So

within Visual Studio Code, we go over here, we go to file and then over here you should see save workspace as. So we can click on this and it will by default open up the the explorer or the finder in the same folder that you are currently in and it will also give it a default name. It will say save as

Python4i.code test-workspace. This is the VS code file extension that you need. So if you set it up like this, there's no need to change anything about this. So this folder is already selected and I can just hit save. So what you now see is you should now see this workspace folder

show up over here and we can also confirm that by going over to the finder or explorer and in the folder we now see the following workspace. Right. So now we can test this if this works correctly because what we can do is we can close out of video code. So now it's gone. We can even quit it. And now we can go to

the finder Python projects Python for AAI and then we double click it. And there we go. We are back in our folder now with the workspace file in here. All right. So now with the workspace set up, it's time to create your first Python file. What we're going to do is we're going to create a new file and call it

hello.py. So let's come back to Visual Studio Code. And what we can do over here is we can either use the buttons over here. So you can click a new file over here, but I can also rightclick and say new file. So let's come in here and let's type in hello.py. Now please be mindful of the extension that you have

over here. So right now you can see that here if I type in hello.py you will see that Visual Studio Code displays the Python logo over here. So it recognizes that this is a Python file. Now this is very important. It doesn't matter what name you give it in here. That doesn't matter. But the extension should be.py

if you want to work with Python files. Now you can also uh for example do a txt to do a text file or you can do a markdown file or you could do a JavaScript file. Visual Studio Code is flexible enough to understand that based on the file extension. So for now do hello.py and hit enter. Now we can open

up this file in our editor and see it pop up over here. So on the left you have your files and now you can see the file over here hello.py. So this is where we can now actually start to write Python code. And the first thing that I want you to do is write a simple print statement similar to how we did that in

the terminal at the beginning of this tutorial. Right? Remember? So we do print and then we do an opening bracket and Visual Studio Code will automatically just by hitting the opening bracket will already create the closing bracket. You can also see how we have different colors in there. This is

all possible because of the Python extension and pyance that we have installed. Then we can do double quotes and we type in hello world and an exclamation mark. So we now have pretty much the most basic Python script that you can think of only with a simple print statement. So let's actually see

how we can run this because in the terminal we would type this out and we would hit enter right but if I hit enter right now I will simply go to the next line similar to what you have in word or any other text setter and I can write more print statements. So now let's cover how we can run this file over

here. And before running your Python file, there's one thing that you should always do at the beginning of every project. And this is also one of those things that in the beginning you often forget it. You just have to double check it. But don't worry throughout this course. We will cover it lots of times

so you'll remember. And that is setting the correct Python installation because we have installed Python on our machine. But we also need to tell Visual Studio Code which Python version to use. Now out of the box generally nine out of 10 times this in right now automatically goes correct because you can see right

now here in the bottom screen you can see 3.13.5. So right now you can see it is using this Python installation on my machine. If I click on this you can see I have more Python installations over here. If you use virtual environments, something we will cover later in this program,

which is a core skill that you need to understand, you'll end up with multiple Python versions that you can select. So, for now, it's important that we select the default one. If you've just installed Python, there's likely only just one version here, but make sure that you refer to the Python

installation that you installed at the beginning of this session. So I click on this and now Visual Studio Code knows okay if I want to run this this Python file here is the installation that I need to use. And now in order to actually run the Python file and execute the code what you need to do is you go

to the top right corner over here and click on the play button. So what this will do is this will open up the terminal window within Visual Studio Code and it will point to the file on our system. So you can see the full pot over here and then it will use your Python installation to run this. And you

can now see that when we run this, you first see the line over here. Where is the Python file located? And then you can see hello world over here. Now I can simply close this out. I can also click in here and I can do run Python file in dedicated terminal. You'll find that this is exactly the same. It create it

will create a new terminal session. The easiest way for now is just to remember when I want to run the script, I can click on this. And now what is actually going on here behind the scenes is something I want to explain. Because when we click on this play button, what our editor does for us, it executes a

command. But if we were to not use an editor like this and simply run this file via the terminal, how would we do it? So let's show uh let's have a look at what what is actually happening. So right now we can also execute this file by saying look we want to use Python and then we point to our hello.py pi file

and we simply run that. So you can see that right now this is also executing this file and it's printing this hello world in here. So if we now close this out and one more time click on this. So let's have a look at what's going on here in the terminal because it's a lot of information but all that there is to

it is first of all it says look we're in this current folder. So we go within our terminal, we go into this folder where we were currently at. Then we point to the specific Python location and before in the example I just did Python, right? But in the terminal when we do this via

editor, it's explicit. So it completely says, look, we're using this version of Python. And then we point to the Python path. So here you can see even though let's see, it's cut off a little bit, but you can see it's pointing to this hello.py file over here. So that is just what you should know about what's going

on behind the scenes when you click on that play button because you could also do this within the terminal without needing Visual Studio Code and you can do it by simply checking look I have the Python command this is available I can do that and I can quit out of that and I can use that Python command to reference

certain files you need to write out the entire file path and now because we're in this folder already we can execute it. So as you are learning the Python programming language, this is really a fundamental skill and an idea that you need to understand. But luckily when we are using an editor, we can just hit the

play button. So we don't have to do it, but we need to understand what's going on behind the scenes. There's also a default keyboard shortcut that you can use and that's Ctrl F5 or CMD F5 on Mac. I actually like to change this. So let's do that right now to see. You can set it to anything you want. So if I come over

here to the settings and then go to keyart keyboard shortcuts and then type in run python you can find the python run python file over here and then under the key binding column if I click in here I can now plug in any keyboard combination that I want. I actually like to do cmd enter and then overwrite that.

There are already commands in Visual Studio Code that have that as well but I find if that you have it like this I can simply now hit cmd enter or control enter if you're on Windows and I can now run this. If this is causing any issues for you or you want another shortcut, feel free to change it or just use the

play button over here. One more thing that you should also know right now is that if you click on this play button or run the code, this terminal will open up over here. And this terminal that we're seeing right here is exactly the same as the terminal we used before, right? So here on Mac you have the terminal, on

Windows you have the Windows terminal. So I can do here python- version and it will show the Python version that I'm using. In a similar way, I can do that here as well. So I can do python- version and I can also run that here. So that's something important to keep in mind. Whenever we're working with Python

code over here and we send it to the terminal, all the things that we can do in a regular terminal, we can also do that here in here right from Visual Studio Code. So we don't have to leave it when later we have to install certain things. So generally, especially in the beginning, you actually don't have to

deal a lot with the terminal. you just close it, delete it and then whenever we need to run something, it will open and then occasionally we need to install some things or tweak some settings and that's where the terminal will come into play. And whenever the terminal is gone, so for example, you X out of it or you

lose it. You can also go always go to the top uh menu bar, click on terminal and then for example do new terminal. Now it will show up again. There's also a default command. It's either cmd or controll J. So I can hit that and that will just like it will not close it but it will hide it. So now if I come in

here and I do python d- version one more time I show it I do uh command j I can hide it and then here you see I have the exact same terminal session still open. All right so now as an exercise you can give this a try and experiment with some different print statements just to get a

feel for what it's like writing code hitting command or control enter and sending it to the terminal. So coming back over here every print line that we have in here will be a new print. So I can come in here and I say print and then I say I am learning AI. And now when I run this you'll find that first

you see hello world and then you see I am learning AI. So whenever you are writing Python scripts you should remember that code gets executed from top to bottom and from left to right. It's pretty much exactly the same to how you read a book. All right. So you can play with it, get a feel for it, and

just know that a simple print statement like this isn't really programming, but it's the first time that you executed a Python file, send it to the terminal, and everything is running. So if you made it to this point in the course already, that is already a huge milestone because if we actually come

back to the handbook and see what we've learned and say always save your work, this is important as well. So come in here, I can hit command controls or you can go to file save. What this will do, it will save everything, all the files, all your work. Uh we have the workspace in here. So now I can simply close this

out and then remember right, I can come to my Python projects, Python for AAI and now I can open up the workspace over here. So this is already such a big milestone because by now we have installed Python on your system. You created your first Python file, selected the interpreter. So we know we have the

installation, we have the app, we know how to sync them and how to point them into the right direction. We created a Python program. Remember, we do hello.py. The pi extension tells us that it's a Python file. And now we understand how to run it and send it to the terminal as well. All right. And now

there's one more quick setting that I want to do with you. And that is the following. If we go to settings over here and then search for tree indent. So you'll find this setting over here. The default is eight. I like I personally uh recommend I like to set this to 20. So look at what's happening over here in

the uh explorer over here. If I set this to 20, you'll find that you have a little bit more indentation in here. Now you might be wondering Dave like what is this about? But is this is primarily if we're going to work with different folders. So let me actually uh if we have a folder in here and let's say I

put this in here and I move it and now I want to see what's in this folder. Look, you can see there is a tree structure in here where you can clearly see the hierarchy. All right, so that was a lot of setup, right? and you are doing awesome and the good thing is that this is just stuff that we have to do once

but I fully understand that as you are going through this with me you might be wondering like Dave I get all of this but how does it all fit together trust me I felt exactly the same way when I was learning all these new things in the beginning but trust me it will get better we just need to set up a few more

things cover some core concepts and then you are actually fully prepared to actually start writing code which from there will actually become a lot easier all right so we're making great progress now the next tab. What I have for you, this is really cool. I have some resources on a resource hub that I

created for this course that I want you to download right now because we will use most of them later. So, if you follow the handbook, you have the resources in the course resources. And now then, if you click on here, you will go to this page. You'll see Python fori resource hub and community access. Now,

this is important because this is where you can access all the resources. So, the templates, files, and cheat sheets that you will need for this course. And don't worry, this is all completely for free. And on top of that, you'll also get exclusive community access to the data luminina academy where you'll find

bonus lessons, advanced tutorials, and also free follow-up courses to continue your AI learning journey. Now, I am hosting this on Gumroad, which made it really easy for me to host these resources, and I can also update them, and then you will get a notification. Now, the only thing is I couldn't select

free. I can just do zero. So, don't worry, you don't have to pay anything. You can just put in zero or any tip you want. If you want to give me a tip or a coffee, that's totally welcome. But also if you want to do zero that's totally fine. You click on I want this and then here you see the Pyth resource hub and

community. You'll see an overview and then you just need to plug in your email address and you can get access. So throughout this course I will sometimes refer to files from the resource hub. So make sure you download that right now. And then the first thing you can check out is this Visual Studio Code cheat

sheet with all of the keyboard shortcuts. There's one for Mac OS and for Windows. And in here are all the default keyboard shortcuts. But this will also give you an ID into all of the actions that are available within the code editor and that you can also change. This is really fun to play

around with and you can really like make it your own. All right. And with the resources downloaded, we can now continue. And now before we get into the Python basics, which you can see over here is the next chapter within this course where we're actually going to write code, execute it, build cool

things, and see how all of this come is coming together. On the getting started page, there's one more section over here called Python environment. And I want to go through this first because it's so so important and it will really help you to better understand what's to come and how

it would also translate to other videos and tutorials you see. So I know that this this is a lot of setup but it is so so crucial and it's that is really what makes all the difference in my opinion from just a a basic Python course that shows you look here's how you can write Python. Yes, we know chatbt can do that

as well, but how does everything work together? And virtual environments is a key component of that. So what we've seen right now, right, we installed Python, we then opened up Visual Studio Code and we selected the Python interpreter that we wanted to use, right? So remember when we were working

in our project over here, you have this whole I have this list over here. You probably have one or two and we selected a a Python version in there. What you should know is that when you are working with Python in the real world, you're often working on multiple projects side by side. And next to Python having a

version like 3.13 within the Python programming language, what we also do is we work with a lot of packages. We can use packages code that someone else has written written and we take that and we import it into our project and then we can use that. These packages also have version. So now we have our Python

installation and we have our packages. Now what happens if you're working on project A and it needs version 1.0 of a tool and you're working in project B and that needs version 2.0 of a certain package. If you now install version two for project B, you just broke project A. So now you might be working on

something. You run your code, everything works. then you like end of the day the next the next day you open up another project you try to run it and now you get an error we don't want that of course so that's where virtual environments come in so these are separated private copies for each

project now before getting into that you need to understand uh packages and what they are about so I already gave a little bit of an introduction right these are uh literally pieces of code code snippets and files that other people created where we now don't have to start from scratch and that is one of

the most amazing things about Python is its like developer ecosystem and all the packages that we can already use out of the box where now with typically just a few lines of Python we can do incredibly powerful things and we can create in incredibly powerful automations. So a very common one is the request library

which we'll be using in this course the pandas library for working with data or the openi library to work with the models from openai. So to create your first virtual environment in our own project that we're currently working on. What we can do is we can use two methods. I'm going to show both of them

to you. We have an easier method and we can do it via the terminal. So let's do the easy method first and this is through the command pallet. So within Visual Studio Code, if you do cmd or control shift +b, you'll open up the command pallet. Let's see what that looks like. If I now do cmd shiftp,

you'll see the command pallet pop up. So if I now do python create environment, you can see this one over here, create environment, right? And then I get two options over here. So fanf or cond. If you don't have cond installed, you will probably only see f for now. Don't worry about what is and just click on fanf.

And now what you can see over here is here you can see all of the Python versions that I have installed on my system. So you can even see that there are some more some older versions 3.9 in here. What I'm going to do is I'm going to select the latest version. And for you there will probably only be one or

two. I recommend just picking the highest version. So we click on that. And now what's going to happen is Visual Studio Code is going to create a virtual environment for us. So you can see it happening over here. We now have this folder. It's called Fenf. And if I open this up, you can see files and folders

in here. And what we've we've now done is we created a local copy of the Python installation. And if I now come back to hello.py, what I can now do, you can see it's already selected over here. Visual Studio Code does an excellent job at autodetecting the environment when it's uh within your project. But you can see

that we now have the ven over here and which stands for virtual environment. And you can select that and what we can do right now if we now click on the play button one more time we will execute the code and we will execute it using our own environment. So I get it this is again this is abstract right at this

point but think of it like this when you're working on different projects you really want to isolate everything and this is a way to get Python within our project in that folder in that folder that we could just created defense and we can make all the changes and all the updates just there. And this is also one

of those things that's the nice things. This is like set it forget it once on a new project. And because we save it in the workspace right now the virtual environment is there. We've selected it. Now if I come back to uh the project over here I save this and I just close out of this. I can come to the folder

over here. Open up the project and then you can see that it correctly selected the virtual environment and I can just come in here and run it without a problem. It is now using our virtual environment that we just created. All right. So that was method number one to create a virtual environment. The easy

method. Now I'm going to show you the second method which is through the terminal. And I'm going to show you this so you understand it that whenever you see a tutorial you understand, oh they're creating a virtual environment using the terminal, but I never use this. So I'm just going to come over

here and I'm going to copy this line. So python- mf and then the name of the folder. And let's close all of this out. I'm going to completely remove the folder again. Now I'm going to open up a new terminal and I'm going to paste the command in here and run it. And what you'll find is that right now you can

see we have created a similar folder. So this is what h what's happening behind the scenes when you do the command pallet python create environment. And now because we have created the new folder in here we should select it one more time just to make sure that we refresh it and we should be good to go

again. So that's another way to set up a virtual environment. All right. Now then a quick note about Anaconda because I want this to be a complete course and whenever you encounter it maybe in another tutorial I want you to be aware of it. So Anaconda is another way of managing Python distributions and

virtual environments on your machine. It's very popular in the data science world and right now I would say I actually don't recommend using it. So I used this earlier on in my career but now when you want to focus on AI there's actually a much better way to manage Python environments and packages. So

later on I'm going to introduce you to UV. Don't worry about that for now, but that's now my go-to. So Anaconda is a whole other application that you need to download and install on your system. It's free, but for now you just need to be aware of it. So whenever you encounter it and someone mentions using

Anaconda, you can literally just replace that with using a virtual environment and just install the packages in there. It's exactly the same. You can so you can still follow along with that tutorial or course wherever they're using Anaconda. All right. And with virtual environments covered, let's get

into Python packages. Another very important concept to understand because out in the world, whatever tutorial or course you'll follow, there is a high chance that at the beginning of the file, they will do some kind of imports and use some kind of packages and I can explain you everything about Python and

how it works and how to write and what it means. If you don't understand this, you will run your code and you will still get an error. That's why I want to start here. So I already gave the introduction, right? Packages are collections of Python code that solve specific problems that other people

created and that we can now very easily download and use for free. It's really awesome. And in order to get those packages and get them into our project, we can use pip. And pip installs these Python packages. It can manage all of that. So we don't have to go to a website. We don't need to do uh go

through an install menu. We can simply run commands from the terminal and it will pull it straight into our project and specifically into our virtual environment. So pip is a command that you need to be f familiar with. So now let's install your first Python package. And to do that we're going to go through

the terminal again. So open up the project and let's see. You can open up a new terminal or I can also do command J to pull up the one that I have active over here. So you can see I have previous sessions. You can close and manage them over here. And if I want to clear it out, I can do clear on Mac or

cls on Windows which is not recognized over here. This is the starting point. This is now going to be the input for which we're going to use pip in order to pull those packages from the internet. So let's continue. So we understand the terminal right now and we are we want to make sure this is important that we are

in our virtual environment. So let me actually check if I did that correctly as I am uh walking you through this and no I did not because I used a terminal session that was already open and later we installed the environment. So let me show you what I mean with this because this is a very common uh mistake. I just

like click on the trash bin icon and now I go to new terminal. I open it up. This will activate it. Look what you can see right now over here. This means that we have a terminal open and it signals that it's using this virtual environment because remember right we have all of the different isolations. Whenever we

want to install something we need to tell our terminal it needs to be in this particular folder. So Visual Studio Code will handle all of that automatically for us. So right now whenever this is available, this is active, it will show up using the virtual environment. One of the most common errors that you run into

if you install packages and if it doesn't work if this wasn't correctly configured. So then you just need to go to okay which is the environment make sure to close it out and then create a new terminal. I'm being a little bit redundant over here but these are the things that will actually give you a lot

of headaches when you are working in the real world. So make sure to take notes and refer back to this video and then you can say ah they've already told me this is exactly because you will make the these mistakes trust me. Now let's install your first package. And we're going to install the requests library.

And the how to do that is really simple. It's pip install and then the name of the package. And in this case, we're going to install the requests library. Let's come over here. Let's clear this out. We do pip install requests. And then we hit enter. It doesn't take that long. Now we have downloaded the

package. What just happened? Well, through the terminal and through the pip command, we connected to the Python package index, which is a huge websites where developers share their code. Then we downloaded a package, which are really just a bunch of Python files that someone else wrote, and we saved it to

your virtual environment. So, let me also show you what's going on behind the scenes because now if we go into our virtual environment folder over here, we can come in here and we go to library and then we scroll down, you can see requests. So, this is the folder. So this is the package that we installed.

And now you can see this is what we just pulled in here. Really just a bunch of Python files that someone else wrote that we can now use. You never have to like look in here. You rarely touch this, but just know that that's where it's installed and that's where it's on your system. And now then in order to

use a package, what you can do in any Python file, you can start with an import statement. And later in this course, we'll go much deeper into this. Right now it's just about like showing you how to do it. So you've seen it once and later like comes the understanding. So right now we can simply copy paste

this whole snippet over here to import the request library and try to download the content of a web page. So if I now come back to my project let's see hello.py. So this is the same file that you should have in here. We can remove everything here and plug this in. And now you can see it is still giving

squiggly lines. Uh, and that can sometimes happen in the beginning. If you selected the right environment and you installed it correctly, this should all work. So now if I run this, we should see that this is now going to run. And there we should get a 200 back. So this is just a status code. So we're

just literally like pinging the website. Again, doesn't matter what that means. You can now see we've imported the request library and it works. So the squiggly lines tells you that there is potentially an import error. And how to usually fix this is if I now close out this project and I open it up one more

time. So come in here and let's open up the workspace. You can see that now it's gone. So sometimes this is a little bit of a bug where it tells you it's not installed correctly. Just reopen your Visual Studio Code. It should be gone. And let's see. We can run it one more time and everything still works. All

right. And that's all you need to know for now about using Python packages. If you look into the handbook, there's more information on this list, but don't worry about it for now. We'll get back to that later. So now the final thing that I want to walk you through as part of the getting started section is

interactive Python. And this is going to be really cool. This is actually one of my favorite ways to work with Python. And when I discovered this, I pretty much never went back. And to this day, almost every day, someone on my YouTube channel, like in in one of the comments on one of the many videos that I have,

someone asked me, "How do you do that?" I have multiple videos on this already, but like this really changed the game for me and how fast I can work and how much fun it is to work with the Python programming language. So, let's set it up. Right now, I've shown you how you can execute Python code using the

terminal. Right, we have this over here. We hit command enter or we do run Python file and it runs. But to me, this always really bothered me a lot because pretty much look at it right now. What's all this mess going on right here? Right, we get a 200 as an output. But there's just

so much stuff uh going on. And there's actually in my opinion a much easier way to work with Python and that is using interactive mode. So let's first set it up and then I'll explain what it is. So there's one prerequisite and we need to install a package and that's why I wanted to share how you can install

packages because you need this one. So what you can do is right now you can simply click on copy or like follow the command pip install IPI kernel. That's the one we need. So coming back to our editor to a terminal session. All right, let's come in here and do pip install ipi kernel. So this will install

everything in there. Takes a couple of seconds. And this will also work with the Jupiter extension that we have installed in Visual Studio Code as well. So we have that and we have the IPI kernel. And now what we can do, we need to change a setting to make this super easy. So the easiest way to do this is

simply copy this whole line because there are a lot of settings in Visual Studio Code. So Jupyter inter so copy this whole line and then come over here to the gear icon to the settings and then I just plug that in there and then you should see this Jupyter interactive window text editor execution selection.

So here you can see when pressing shift enter send selected code in Python file to the Jupiter interactive window as opposed to the Python terminal and we select that. That's it. Now if I close out on this. So we have the same script over here. And now what I can do is instead of hitting command and enter to

like run it in the terminal, right? That's the uh hotkey that I set in the beginning. What I can also do is I can select a certain section of the code. It can either be everything or a single line. And then I do shift enter and a window to the right will open. And now you can see the 200 status over here as

well. So the difference is is that instead of like taking the entire file and sending it to the terminal and then all of the outputs showing up in my opinion in kind of like a messy way with a lot of like noise in there, now we have this very clean window here on the right where we can see the output. But

it even gets better because instead of just running the entire file from like top to bottom, what we can also do is we can also execute certain sections or certain lines or pieces of the code itself. So I can come in here and when I am on a single line, so I'm now on line one and I do shift enter. You can see

that we only run import request. So now we import the library and I can for example also just run the request over here. So just do that. So I just get the response and then finally I do the print statement. So, not only does it allow us to have a cleaner interface on the right, it also allows us to go through

our code more in a more granular fashion and highlight certain section of this. So, as we go through this course and as we start to actually work with the Python programming language, this will really become apparent to you as to why this is nice and why this is so useful because we can check back and we can

actually go here and say, look, we can even select partial lines. So, not even a full line, but I can do a selection and I can use the shift and the uh alt and option keys to go through this and even look at specific variables in here. All right, so that was the getting started section. Congratulations. We

already covered a lot. Now, this would also be a good moment to take a break and to really think about what we've learned so far. So, let me quickly walk you through it. Right. So, when you started with this course, you did not have a Python installation. So, we got that onto your system. We got Visual

Studio Code. You have the application. You now know how to create projects in there. Save them as a workspace and then you also understand the importance of virtual environments to create isolated in instances of the Python programming languages so that we can install the packages. You've seen how to work with

the basics of Visual Studio Code, the extensions, how to style it. You know how to run Python files either using the terminal or using the interactive window which I am a big fan of. So right now you really have all the tools to start to get to work and you are so much better prepared than pretty much anyone

else trying to learn Python because this really is a cheat code. Everything that I shared in here and that I boiled down into this step-by-step format, this all really took me years to learn. And I really wish someone in the beginning of my Python programming journey like literally over 12 years ago, I wish

someone would have shown me this approach because it's a complete gamecher. And now if you're up for an exercise to really check if you understand this, here's what you can do. And I in the beginning this is tricky because I've given so many Python trainings already and students follow

along up until this point. But then when they start again from scratch and they have to do it on their own with without essentially me like holding their hands and showing everything step by step, it can get tricky. So here's what I want you to do. Go to your Python projects folder and create a new project. So in

there, create a new folder, give it a name, and then I want you to open it up in Visual Studio Code and go through the entire process. Everything that you need to do in order to set up to create a file, put some Python code in there. You can do a simple print statement similar to what we already did. use a virtual

environment. Make sure you select it and make sure that you can run it both in the terminal and in the Jupyter interactive session. Make sure you save everything to a workspace and then close it out to see if you can open it up again. If you can follow along with that, you pass this first section of the

course and you're ready for the next stage. All right, so welcome to the Python basics chapter. We are now actually going to start writing Python code and learning the language, learning what this is all about and how we can use it. So now with our environment set up, VS Code ready, our everything

installed, we can use our Hello Pi file. And this is going to be the file that I'm going to continuously to work in. You can use this as a scratch pad, right? You so you can be sloppy in here. You can put some code in there. We can run it and then the next example, we can get back to this and we can keep using

this. So we don't have to worry about managing all of the files. So what I'm going to do for now is I'm also going to close the sidebar over here to create a little bit more real estate on the screen here. And the command for that is command or control D to show the explorer. But for now, this is what we

need to do. Okay. So coming back to the foundations, we're going to start with really the very basic building blocks of the Python programming language like variables, data types, operators. But before getting into that, I want to give you a little bit of an understanding like to understand the bigger picture of

what programming is all about. Now, if you're coming from a different language, you can skip this part because you're already fully aware with this. But if you're completely new to programming, I this is a great moment to take a step back and to explain you what we're fundamentally doing. Because when you

are following this program like step by step, action by action, you are so zoomed in into following exactly what I do, right? Installation, I get it. The app, I get it. An environment and but you need to understand what's the goal of all of this. What are we trying to do? And programming is all about writing

instructions for computers. And computers are very literal. So you need to tell them exactly what it is that you want them to do. So if you for example tell a friend of yours like hey go make a coffee like internally they understand that they need to get a cup add coffee grounds pour hot water wait a couple of

minutes the whole process right a computer doesn't understand this so when we want to try and accomplish something when we are trying to automate something where where when we try to create an AI agent or build a model we need to be very specific and we need to instruct the computer in such a way to follow the

exact order of operations in order to accomplish our goal and there are many ways to do that and many ways and many programming languages to accomplish that and Python is one of them. So that's the first thing that you keep in mind. We are working on all of these isolated bits and pieces that in isolation don't

mean a thing and are pretty useless. But when once we start to understand all of these building blocks and we start to combine them in different ways like Lego blocks, we can now all of a sudden create an AI chatbot. We create an AI agent. we can uh create a simple script that can take a document, extract

information, give a summary and put it into a CRM. It open up opens up a whole world of possibilities which we can all do through the Python programming language. So that's what I want you to keep in mind as we start with these really really fundamental concepts. They're isolated. They're small. On

their own, they mean nothing. And you're probably wondering like what can I automate this? What does this have to do with AI? But once we start to layer them, that's where everything starts to click. And with all programming languages, there are only a handful of basic operations that we do over and

over again. So here the first one, a very common one is storing information. We want to get some type of data and we want to store that information so that we can process it. Let's say we have an age 25, a name is Sarah. Now later we can use that. We can reference Sarah by using the name variable. We can also

make decisions. we can use if and else statements. So if this happens, we do that. But if that is the case, we do that. This allows us to make smart programs that don't only do just one thing, but based on the data and the information that is coming in, we can make decisions. Programs can also repeat

actions. So they can repeat things 10 times. So when a document is coming in maybe it has like 10 pages and for every page we want to do something maybe scrape the data extract it and then calculate things. So what's the total price? We have numbers. We want to add them, subtract, sub subtract them, apply

any kind of math. And through this storing information, making the decisions, repeating the action and calculating things, we can solve a lot of problems actually using a programming language. All right. And then now let's get to the next section which is called Python syntax. This is all about how we

properly write Python code. And similar to the English language where we have grammar, Python and every other programming language for that matter also follows follows certain rules. And instead of grammar, we call it syntax. So this is an important topic to understand. Even though Python is known

for being very clean and readable, right? We saw that in the beginning. It pretty much just reads like plain English, there are still rules that we need to follow. And this is good of course because otherwise all the code from everyone would look different and it would all be messy. So throughout all

of the following examples I will refer to the specific syntax and just know that if you ever run into an error there is a high chance that you will have some type of syntax error. Maybe it's a bracket that did not close. Maybe there is a quote missing. Maybe the indentation and the spaces are off. It's

literally that tricky. So remember that for now. Syntax is all about how you write Python code and the rules you need to follow. And now as you go through this course, syntax is something I will bring up all the time because whenever I introduce a new concept, we will start with the syntax first. How to write it

and what are the rules. And one of the most important things there which is also unique to Python is the indentation which is the spacing that we use to separate blocks of code and to bundle pieces of code together. So if you for example look at a JavaScript language you can for example use curly brackets

and that signals look everything between these curly bracket belongs together. With Python we solely do that through indentation. So we'll go through indentation rules which we will constantly use and our editor will also help us with this because whenever we go to a new line where we need an

indentation VS code will automatically do this for us. Now don't just worry about that right now. It will all become more clear as we go through the examples. But just know that indentation rules and using those four spaces is important in Python. Now, beyond just syntax rules that make your code run,

Python also has style guidelines that make code more readable. And we as developers have agreed to a certain standard and these this is called PEP 8 or the Python enhancement proposal 8. This is the official style guide for Python code. It covers things like that. We use four spaces instead of taps. We

limit lines to 79 characters, naming conventions like using underscores lowercase instead of using camelc case and where to put spaces around separators. And now as we go through this course, I will follow these PEP 8 style guidelines so you don't have to worry about them right now. But just

know that there are rules for indentation for how we work with spaces, blank lines, and even line length. And at the end of this course, I'm even going to introduce you to a tool that can automatically take care of that. All right. So now let's have a look at what happens when you don't follow the syntax

and you break your code. So let's say we do another print statement. Then we type hello world but then we remove the final quote over here. And you can already see that our editor is giving us these red squiggly lines indicating that something is wrong. So the string literal is unterminated meaning it is opened but

it's not closed. But for the sake of demonstration I am going to run this code. So what I'm going to do in this case I'm going forward. You will see me do this over and over again. My cursor is here on this line and I am controlling that with the arrow keys left and right. And now on this line I

simply press shift enter. And what this will do is it will open up the interactive window over here. And now here you can see the error. So you can see the line on which the error occurred. You can see it starts here. We opened up a string and then you see this syntax error. So now you know what

syntax means and where this is coming from. So it says unterminated string literal detected which is just Python's way of explaining you opened up the string but you're missing a closing quote. So if we plug that in here and run it one more time, you'll find that the code will now run without any errors

and we will get the hello world statement. And now reading errors is something you have to become good at because errors do not only happen when you're a beginner. Trust me, making errors is literally part of programming. even like the best programmers in the world, you build programs by trying

things out, breaking things, and then fixing the bugs. So, it's a core part of the development process. So, how you read Python errors is something you get more and more used to, but there is a general principle that you can follow and it's in the documentation over here as well. So, first you'll see where the

error happened. So, here you can see this is in line one. We're running the interactive session with this file. So, this is where it happened. Then, next you can also see what went wrong. So all the way at the bottom of the error and this is right now in this example this is a pretty short error. There can be a

lot of information all the way at the bottom the final line you'll see in this case the syntax error. So Python will tell you what went wrong. And then the third component is the arrow pointing exactly to the spot where it happened. So following this three-step process to debug your code whenever something goes

wrong. Look at what happened. Syntax error. Okay. Where line one and then you can see the exact snippet. Oh, it is something to do with a string. Now, in the beginning, all of these syntax errors right now, they will seem very alien to you. Unterminated string literal detected at line one. Pretty

abstract, right? This is a great spot. This is a great time to plug that into your AI assistant or just plug it into chat GPT and ask, look, I'm writing a Python program and I get this error. What does this mean? And if you show your code even better, it will tell you exactly what went wrong and how to solve

it. And over time, you'll get a much better feel for quickly spotting errors and what went wrong. And your IDE will also help with that. And in this case, we could have easily prevented the error because our IDE already signals that we need to close the string. And now throughout this course, if you follow

along, you're going to make a lot of errors. And that's the goal, right? Because with that, you'll become more and more used to it. That's also why I keep hammering on make sure to write everything out and not just simply hit copy paste on all of the examples in there because then out of the box they

will be good but you need to train yourself in order to spot the differences to spot the spaces to spot the quotes. So make sure to type it out on the keyboard make those errors correct them and continue. All right now it's time to get into one of the most fundamental concepts in all of

programming not just the Python programming language but in general and that's variables. And variables allow you to store and name your data. So coming over to the hello.py file over here. Let's say you're building a program where you want to take in some user information. So you want a name and

let's say we set that to Alice. This is Python's way of setting a variable called name and we set that equal to Alice which in this case is a string. We can now run this program and if we now come over here and we make a reference to name under the hood Python now understands that name is equal to Alice

and similar I can for example set H to let's say 25. So now if I go in here and I just run H which I do here with the interactive session which I can do by putting it on another line hitting shift enter but I can also do it by taking the cursor and just selecting this part. So again I'm using this with the arrow keys

and then I'm holding in shift. I select this and I do shift enter to see under the hood what the variable is that is assigned over here. So we can set age to 25 and we can also overwrite things that's why they are called variables. So if I for example now say name equals and now I for example say Dave and I run

this shift enter we can now check and now Python understands that name is equal to Dave. So this is how we can pass data around and we can do that with all kinds of data. We can do that with strings which you see over here. We can do that with numbers and we can even do it with uh true or false values. So we

can for example set is student and then we set that equal to true which is also something we can do in Python. So the things to keep in mind here about the syntax about working with variables is that on the left you have the variable name. Then you use the equal sign which means you store the value on the right

in the variable on the left. We store Alice on the variable name and Alice is the value that we're storing. Now there are also some rules that you should keep in mind when working with variables. So here you see all kinds of variable and variable names that are allowed. So we can use an underscore, we can use a

capital letter, we can use a number in here, we can even use an underscore over here. But there are also some things that are not allowed. So for example, a variable name can start with a number. It cannot use a hyphen or it cannot use a space. And you can also not use certain Python keywords. And we can

validate that by coming over here, getting rid of this, and then say to age is 30. When I run this, you'll get a syntax error. So we get an invalid decim decimal literal. This is not possible. We can also do new age is 30. This will also not work. So here is an example. Things that are allowed, things that are

not allowed. And to make that even simpler for you, in the Python naming conventions, we use lowercase letters with underscores between words. This is also called snake case. So when we for example want to spell out a first name is Alice or a user age you can see that instead of doing a space or a hyphen we

use an underscore. So if I do first underscore name and then I set that to Alice I can run this and it will be no problem. We can just store this similar to user age equals 25. That's all fine. So the important thing to keep in mind here is that there is a difference between the strict rules of Python. So

when it will actually throw an error versus the style guides because within Python it's totally fine to use capital letters here in the middle of a variable which is called camel case. I can do that right now. So first name with capital N equals Alice. I can run that and it will not throw an error. But this

is just a style thing. This is not something we do in Python. So to make that simple when we talk about variables lowerase and when you need to create a space use an underscore. And now, as we go through all of these examples, I want you to know that in the handbook, there's almost always a little bit more

information that we don't cover in the video. So, common mistakes, things that go wrong, more examples, but otherwise, it would be a 10-hour long video. So, I cover the basics in here, what you need to know. But if you're still like, hm, variables, I don't still quite get it. Make sure to go through the handbook and

then ask follow-up questions to ChatBT or your favorite AI assistant if you still need additional help. Next, let's get into comments. So, what are they and how do we use them? So, if we come back to our script over here, you can see that in here we have the first name, we have the username. This is code that we

execute. But Python also allows us to put human readable comments in our scripts that Python will simply ignore. It will not do anything with what we put in there. We can put anything we want in that case. And we can use descriptions. We can explain certain bits and pieces. We can add to-dos or reminders. And this

is a way for us as developers to not only uh help our future selves, but also potentially other people with which we work on the same project. And the way we do that within Python is by doing a hashtag. So if you type a hashtag, you'll see that on that whole line starting with the hashtag, it will be

grayed out. So I can start typing in here and I can say this is a comment in Python. So you can see it is grayed out. And if I now select all of this and I run this, nothing will happen with this. It won't output anything similar to what we have with Alice and the user age. I can for example put a print statement

over here to actually show you. If we do the user age and add that to it as well, I can execute this whole line and it will print 25 because we have instructed Python to print this. Similar to this, we can also run this in the terminal and you'll find that the output of this script will just be 25. So there will be

no trace of this comment whatsoever. So we can do that on a whole line like this. But we can also do it after uh at the end of a line. So if I'm here and I want to write a comment saying this is the first name, which in this case doesn't really add a lot of value, but let's say you wanted to give a little

bit more clarification. This also totally works. We can also do multiple lines by coming over here saying this is another comment. This all works. No problem. Now, if you want to write comments over multiple lines, there's actually one other way that you can do this and that is by using triple quotes.

So, another way to write a comment is doing it like this. You'll see three opening quotes and then I can go over here and I do three closing quotes. and anything that I write in between here. For example, this is a multi-line quote that can go on and on and on. And in this case, you don't have to start every

line with a hashtag. And this helps for readability. You'll also find that this is green instead of the grade out version in here. So, typically, if you want to do short and snappy comments to just give a little bit of instruction or clarification, you use the hashtags. If you want to have more explanatory

paragraphs to later also describe functions and classes and what they do and what kind of data you need to put in there, then you'll use multi-line comments with the triple quotes. And as a rule of thumb, you want to use comments to explain the why, not the what. Because since Python is relatively

easy to read and it usually reads like plain English, you for example, here's here's a bad example. So let's say you have you want to calculate a total and you take the subtotal and you m you multiply it to calculate the text and then a comment here is multiply subtotal by 1.6 like we can already tell that by reading

this line. But over here in the top example, we for example have a tax calculation. And if if people are from California, I I don't think I think this is off. But let's assume this was correct. You explain the the calculation why you're doing this. So someone looking into this code might might be

like, okay, what's this number? Oh, it's to calculate the sales tax. So that's a good reason why instead of explaining what. Okay. And up next, we're going to talk about data types. So these are the different kinds of information that we can store in Python and when we were experimenting with the variables right I

already brief briefly mentioned like look it can be a string which is text it can be a number it can be a true or false so let's cover all of the options that are there because that's also a fundamental concept that you need to understand and let's start with numbers so under the hood there are actually two

types of numbers when you are working with Python and with most programming languages If you're new to programming, this is always a little bit weird like why why is it different? There is a difference between what we call integers and floats. And integers are simply whole numbers without decimals. So 25.

And we could set h equals 25. And this would be considered an integer or floats which have decimal points. So 19.99 that's a float. Now in the real world in practice, Python is so flexible that you often don't really have to think about this. and you can just write your programs as is and Python will

seamlessly convert one into the other. But under the hood there is a difference in how they are stored in memory. Uh why is this? It simply has to do with efficiency about how the computer like can process it. But that's all you need to know for now. So what can we do with numbers, right? Well, we can apply basic

math operation. It works similar to how you would use a calculator. So let's run through all of the examples and show you how that works. So if we come in here and we can literally like use this as a calculator. So we can do 5 + 5 and we can run this shift enter. You'll see this 10. We can do a minus it will be

zero. We can do multiplication with an asterisk. We can do a division. Everything works like this. And we can also store that into variables. Right? So let's say we have our total and we want to calculate. we have 10 and we do it minus 7 and we come in here we store that. So now we do we perform the

calculation and we store it in the total. I come in here and I run that we can see three. Now again as I go through this just remember because we're using the interactive session instead of having to write out print all the time and print what the total is I can come in here and just select total and run

it. And we can also do powers. So power equals we could do 10 and then we use double asterisk. let's say to the power of two and then this should be 100. So give it a couple of tries. Make sure to play with this and also to get used to typing to selecting the pieces that you want to see and just get comfortable

with this interactive window over here knowing at all times that this is quite a unique way of working with Python. And if I run this script like this, you'll see nothing is happening. There's no output because there are no print statements. So if I were to print the power in here, I would need to like

explicitly write that out, say print, and then run it in the terminal session like a lot of other examples you'll find online do. Then you see the 100 over here. But with the interactive window, we can just start it up. Come here to the total, say, I want just this. I want just this. And I want to see the power.

And here in the beginning, I know that I'm repeating myself with this, but you need to get those reps in in the beginning. you need to see like how I go through the code and select things and I am so used to this for me it's seamless I'm using the arrow keys I'm using shift but I'm I totally understand that when

you go through this you might be like oh what how is he doing that so fast so follow along run the examples try and build your own calculator see what it does and as you go through all of those examples you'll build the muscle memory to do it just like I do all right so those are numbers and the basic math

operations that you can do now let's continue to the next data types And those are strings. So strings is just a fancy word of for text. Any type of text we can put into a string. And in Python we do that between quotes. Now Python doesn't care actually if you use single or double quotes. You just got to be

consistent with this. I always use double quotes. So you can also just do that. Totally fine. Just be consistent. And now there are a lot of things that you can do with strings. So let's run through a couple of examples. So I'm going to create a string here. And I'm going to say my name is Dave. This is a

string over here. And we can even add some comments just showcase everything that we learned. And now I can select all of this and run it. We'll open up the session over here. So this is how we create a string. And in here we can put anything really. We can even go as far as let's say let's create my long

string. We can also use triple quotes. And remember how we could also do that with comments, right? But if you do it after a equal sign, we can put in a long string. So you can say my name equals Dave and um my last name is Eilar. So in this way, let me clear up the capital letters over here. We can do this string

and this is one line, but we can also have a long string. And if we now show and look what's in here, you can see that we have multiple lines in here. So that you can see by this uh back slashn that signals that it's a new line which actually means if we print that. So we can print my long string it will show

and it will print that on a new line. So those are the two ways that we can specify a string and put it into a variable. Now with the string as a data type there are a lot of operations that we can do. So remember when we had numbers right integers or floats we could perform math operations. So

strings have similar features. So one thing that we can do is for example first name let's set that to first name equals Dave and then we say last name equals Ear. What we can now do for example is we can set full name equals and then we do first name and then we do a plus sign. So we can actually perform

some kind of like math operations on strings and then we say we want a space in between. So I do an empty string over here with just a space. Then do another plus sign and then I do last name and write that in here. Let me make this a little bit smaller for you so you can so you can see the full line. You can see

everything. So now if I run just this line you can see first name is not defined. Oh yeah this is a very common error because I forgot to uh run these lines of code. So first I need to store this in memory. So now you can see over here Python understands okay first name is Dave and similar to last name is

Eilar. And now when I run this whole line you can see that this will run and I can get the full name out of it. Okay. So now we're performing what's called string manipulation. And there are a lot of actions going on here. So try to follow along. Try to put everything in. Try to run them line by line and then

look at what's in the variables. Try to select them. Get a feel for working with this programming language and the interactive window. Now what we can also do is we next to the plus sign we can also for example let's say we have an asterisk and we can say or let's let's actually do a dash. We can do a dash and

we can say long dash equals and then we do the dash and we do it times. Let's do it times 10. We save that. So let's see what we have over here. Now we have well we I think we can do longer. Let's actually do um 30. So now you can see we have a really long dash. So now if you for example wanted to create a program

and you want to display some information. So first let's say you print and then you do we do the full name. So we can print the full name and then afterwards we print the long dash. You can see if we do it like this. There we go. And now we can tailor it to kind of like the length. I think it will be

around 12. So now you can see we have our name and a dash underneath that. So if you want to do some print statements or logging this can be helpful. So there are things that we can do with strings as well. Another operation is we can also check the length of a string. And this is using a Python built-in function

similar to print. So if I type print, you will see that it turns blue, right? This means that this is a built-in function from Python. And how do you know if it's built in? In the beginning, you don't know. That's why you're going through this course. As as you'll find me explaining variables, sometimes there

are just things off the shelf that we can use. And so getting the length of a string is also a built-in function, and that's through length. So not the complete length but we shorten it. And then for example we can plug in the long dash in here. And if we run that you'll find that it says 12. So what this

function does is instead of just print instead of just printing it it will take the string and it will calculate how long it is. So if I take the full name and do that you'll find that my full name. So that's the first name plus the space in here plus the last name equals 13. So that's a length of 13. Whereas if

I plug in my first name, the length should be four because my name has four letters. So that's a built-in function that you can use. Now there are many many built-in functions and we'll cover some of them and as you progress on your Python journey, you'll encounter more and more of these. So when you're trying

to solve a particular problem and you ask JBT, how do I do this in Python? Sometimes it will tell you look there's actually already a function or later a package for this that you can use. Now that's all you need to know for now about using strings. We can store text, we can manipulate it and we can do

things with it to process information. Now next let's get into the third data type and those are booleans. So booleans are simply true or false. They can just be that and they are very handy in programming to make decisions because based on whether something is true or whether something is false we can make

decisions and we can route our program or our data either to for example to the left or to the right. Now and one common example of this is so we with data luminina we build a lot of customer care automation systems and one of the steps that we have in there is we let an AI decide whether an incoming ticket should

be escalated to a human. So there's a whole processing logic behind that but ultimately what the AI decides is escalate is true or false and when it's set to true meaning it should escalate we route it to a human to refute and if it's false the AI can handle it themselves. So th those are booleans and

we literally write it out with like a true or a false and we use a capital letter. That's a syntax thing that you need to remember. So if I come in here and follow the examples. So let me clear this up. We can say let's say we have a user status and is uh logged in. If we set that to true, you will see that it

will turn orange. This means this is the actual boolean the boolean value within Python. If I don't do the capital letter, you'll find that it's it doesn't turn orange and it will give the squiggly lines where it says look, you should not do this. It should either be true or it should be false. So those are

boolean values. So right now I can say is the user logged in? This is false. Now booleans often come from creating comparisons. So we can do a direct assignment which is what we just did, right? So we can say is true and we can literally just set that to true. So that is a direct assignment. But we can also

perform conditional logic to decide whether something is true or false. So if you look in the example over here you can do a comparison. So let's go through this and let's say someone is 18. So we have age is 18 and then we create a variable called can vote and then we do a comparison where we say look we take h

and we check whether it's greater than or equal to 18 and we store that can vote is true because we have set age to true. So this is another like very cool way you can where you can play with the interactive session by just selecting this over here. So again I'm using the arrows arrows. I'm holding shift and

then I select just this piece over here. And now I can check this. This is now true. But if I for example set this to 16. So age over here age now is 16. And I do a comparison whether it's greater or equal to 18. You'll find it is now false. And now if I run the entire line I can now set can vote to false. So, do

you already get a feel for what this is like and how this works? So, now the uh comparison operators in here. That's just one of those syntax things that you need to see a couple of times in the beginning. So, let's actually see what we can do over here. So, you have things like equal, which we do with double uh

equals. So, remember the assignment of a variable is with one equal sign. But if we do two equal signs, we actually form a comparison. So if we let's let's again let's set this to 18 and then let's see we make another like we do is 18 is a variable and then we check whether age is equal to 18. So we set the age now

it's 18 look then we perform this it's true. Now we do this not true. So these are ways that we can perform really any type of comparison that you want to make. So coming back over here, is it equal to? We can also is it not equal to? So we invert it. We do that using an exclamation mark. Then we have greater

and less than. So we could use greater than 20, less than 30 or greater than or equal or less or equal. So these are all the types of common operators, right? If you ever built some kind of like logic or worked with a program or worked with something like sapier or make.com or nat

these are very common operations and this is just a way this is just a python syntax to write that out. So this is something you won't remember right now. So this is always something you have to refer to. That's also really one why I wanted to create this handbook. So you can bookmark this and whenever you're

working with variables you can come here in here check it out or of course simply ask AI and it will also tell you what to do. Okay, so those are booleans and again as with any section if you're running into errors make sure you check out the common mistakes. All right and up next we are going to the section

working with data. So we already covered the math, right? The arithmetic operators to do simple math and to perform calculations. And one thing you should know about Python is that it it follows the same rules really when it comes to arithmetics that you would use and on your math math exams in high

school, right? Or when you're using a calculator. So for example, the multiplication becomes for an addition. So this will be 14 and not 20. And if you use parentheses, that's how you can prioritize certain operations to do them before. So, similar to what it was like with math in Python, it works the same

way. Then we have the comparison operators, which I just shown you. And feel free to stop here and take some time to play with these. I'm quickly going over this because I want to get to the logical operators because we can also combine boolean values and conditions and we can even include the

words and and or. So let's have a look at what that looks like. So let me actually take this snippet over here and we're going to play with that. So let's see over here we have h equals 25 and let me actually I can zoom out and I can clear all of this for you and then zoom in a little bit. So we have age is 25.

We have a license which is true. And now we perform a check and we want to perform a check and both must be true. So to determine whether someone can drive both the age needs to be like in the US needs to be greater or equal than 16 and also has a license should be true and this is also one of the cool things

about Python right because look at how easily we can read this it's almost pure English so let's go through this can drive we set that equal to and then we perform the first operation so age is greater than or equal to 60 is that the case it's 25. So let's check that. Let's just run this line. That is true. Okay.

Now we see end over here. And we have has license. So has license is set to true. So what now will happen if we use the end? This line over here. This will output true if both of the clauses in here are true, which is the case. So if I now run this, you'll find that this is true. And if we then print can drive it

will be set to true. But if we now set this to false. So someone is 25. So they are still over 16 true but has a license is false. And now we run this and print can drive is false. So you can see how we can now start to build this logic right. And similar we can also do or and this means it's either one of the two

should be true. So if we do it like this, they can still drive because they're 16. This is maybe in like some weird country or state where you can either have a license or 16 and you're good to go. So coming back to the examples over here, you'll find that you can combine these in all kinds of ways.

So whenever you're trying to solve a problem, even if you want to stack 10 conditions and very complex combinations of all kinds of variables that you can think about using all of these operators equal to, greater than, and or and using these truth tables and understanding how they work, you can see that you can

almost like create any kind of decision-making logic. So go through this and here can here you see understanding the truth table. So that this is what I was going uh for true and true will be true and this is using the and this is using the or and not is another one. So this is how you can flip

it. So let me actually show you what that looks like. So let's see if set has a license is set to true. Let's see. Let's do that. I can also now for example do not has license. And now if I run this this will say false because has a license is true. And when when I invert that it turns into false. So

let's do another example here. Let's do drunk. Let's say drunk is equal to true. So can drive now becomes age should be greater than or equal than 16 and has license. And here's the thing. You can also do equals true. But you don't need to do this. So this is like as you type it out, you might want to do this. But

since has license is already a boolean value, you don't have to make a direct comparison with this. But both will work. But let's for the sake of simplicity leave it out. And then also we do the third clause in there. We literally say and not drunk. Okay. So now what you can see over here, let me

actually zoom out a little bit so you can see everything. Now if I run this can drive like make sure we have everything in here in memory. Now you can see if we run this and then we do can't drive is false because they're drunk. They're 25. They have a license but they're drunk and they cannot drive.

If we do it in false, they can't drive. Now here was one more Python trick that you'll often encounter. There are also shortcut assignments. So when you have a score, let's say score is 10. So I come in here, let's clear everything out. Let's say score equals 10. And you want to add something to that. You could say

score equals score. and then we add five. So now score will be 15. You can also directly do score plus equals five. And then we add another five to the score and now it's 20. And we can do this over and over and over again. So if I run this a couple of times, you can now see score is 90. So this is a simple

shortcut assignment where we don't have to do this redundant like score equals score + 5, but we can do it directly and this works with almost all math operators. All right. So, those were some common operators. Now, let's get to into the string manipulation. And I want to show you two more things when it

comes to working with strings that can be that are very useful, especially when you're working with AI and when you're working with prompts. So, we already saw that you can use the plus sign, right? But now I want to show you frings. So, let's see what they are and why they are so common in uh when you're working with

AI and language models. So let's say we have our string and let's say we have uh let's say we do hi there my name is Dave. We can run this. We have the string and we have their hi name there my name is Dave. But let's say you have a program and you don't want to hardcode this name but you want to do it based on

the username right? So let's say name equals Dave and then oh I should put that in quotes right to make it a string. How can we now make this in such a way where we make this dynamic and we replace this with the variable over here? So now depending on who is interacting with the system, it will

give them a different greeting. And this is used all the times when you are working with AI models and prompts, you want to dynamically inject information that you retrieve from another system, store that in a variable and then put it in a string. So the way we do that in Python is through what they call

fstrings. And this is again this this is now a syntax thing because this is just something you need to remember. There's not really any logic behind it, but it's called fstrings. And we literally put an F before it. So you have the string, you have the quotes, and you just put an F

in here. And when we plug that F in here, what we can now do is we can come in here and we can use curly brackets and we can now plug in any variable. So you can now see that this is a string and it's not giving us any errors. And if I now run this and I print this, you will see that if I move my oh wait, let

me actually move myself to the left side so you can actually see something. So here you can now see my name is Dave. And if we change this to I don't know John and we run this you'll find that the string is now hi there my name is John. So that's the notion of fstrings. Super useful. And let's see if I for

example get rid of this you can see right now if I run this and print it you can see that it literally like hardcodes the curly brackets in here. It it will be orange. So it will Python will indicate that it recognizes that you want to do something there but it will literally just print it out exactly as

is. So that's why you need to put the f there and then it works. Now then another thing that I want you to know about strings is that in Python you have a lot of what they call string methods. So these are methods functions that you can apply to a string and it will perform an action. And the way you do

this is so here's an example. So you have text, you have the string in here and instead of putting it before it, so print and then using the the brackets, you directly take the string variable, you do a dot and then you apply the string method by typing out the method and then using the brackets in here. So

let's follow uh let's follow along with this to get a feel for what that is. So let's say let's come over here. We have Dave and we can do name. We do dot lower and then we do the parenthesis. And now you can see this is my name in lowerase. But I can also do my name in uppercase.

Let's see in uppercase. And I can even do let's say if we have a sentence. So you could for example do sentence equals hi my name is Dave. You can even do a title. So you can do sentence.title and then it will apply title case if I store it in memory. And there we go. So you can see it will capitalize all of

the first letters. So these are called string methods. And I'm going to show you one more example over here. I'm not going to walk through everything but you can even see if you have this message over here. So I love the Python programming language. We can also for example uh create some boolean logic

around this where we can say starts with ends with and that gives us true or false values. We can find certain phrases within a sentence. We can count the occurrence or number of times Python is occurring in this message and we can even replace certain parts. So here if we have the message and we replace

Python with JavaScript it will now print I love JavaScript programming with JavaScript. now and I totally understand that that is a lot of information right and you definitely don't need to remember all of that like even I often have to look up these things like oh what was it again like there's something

in Python with starts with and ends with these are such niche use cases that when you need them all you need to know is that Python has a lot of functionality out of the box to solve common problems so whenever you're dealing with something there is a high chance that you don't need to come up with the

entire logic yourself or create a really complex function, you can first just ask chatbt and say, "Look, I'm trying to solve this problem. I need to I have this sentence and I need to understand if it if it starts with this and then I want to replace a certain part and JGPT will literally give you the most

effective way to do it through a combination of all of these methods that I just shared." So the goal really is to get you familiar with what you can do with data. What are string methods? What is the notation? seeing them, walking through them, and just getting a feel for how this programming language works

is really the goal at this point, not to fully understand and remember everything. That's important to keep in mind. All right. And now we get into the section control flow. So, how can we actually make decisions within our program, right? We've already we already saw that we can use true and false and

we can do calculations. But now whenever we're building programs, we need to do something like look if at an ATM a password is correct then we allow access. If not we give an error. If a user clicks on a button only then we perform an action. In a game if the health is equal to zero it's game over.

Otherwise we can continue. And within programming we do this through what you call if statements. So let's run through some examples. So let's say we have a temperature and we set that equal to 25. Now what we can do is we can build a system that based on the temperature does either a certain action when it's

above a threshold or something else when it's below a threshold. So we can simply start by saying look if the temperature is greater than 25 we now use a colon and we get to the next line. This is something new. We haven't done this. So we introduce the if statement which is an operator that we can use. An if

statement always just starts with the if. Then we have the conditional logic over here and then when we end that logic we do a colon, we do a enter and then we get to the next line and here we use an indentation. This is very specific to Python. So it goes to the next line and what's doing uh what it's

doing behind the scenes. You can see in the highlight over here it's adding four spaces. Now our code editor is doing this automatically for us because it understands the Python programming language and it understands what it does. So just so you know that's what's going on behind the scenes. And now what

we can do is we can for example write a print statement over here where we say it's hot. If we run this nothing will happen. And that is because the temperature is equal to 25. If we set it to 26 and we run this it will say it's hot. Remember right similar to the example I gave about the customer care.

Do we need to escalate it to a human? Yes or no. This is it's a similar type of logic. So let's set it back to 25. Nothing will happen. Now let's create another case. So what we can now do is we can now go back. So we exit out of this if statement and we continue with an else statement. And now here we don't

have to specify any logic because this will simply execute in all other cases. And then we say print it's nice weather. Now if I run this it will say it's nice weather because if we follow the order of operations which in Python will be from top to bottom and from left to right it will first check if the

temperature is greater uh if the temperature is greater than 25 it will print it. This is not the case. Okay. Now we go into the else condition. This will always run. If this is not true this will run. That is how it is currently set up. It's it's a boolean boolean decision-making logic. And now

the syntax here with if and then a colon and an else and then nothing there and another colon is just one of those things. You just have to see it and do it a couple of times before it clicks. But let's say you want to add more conditions to the mix. So actually what we want to do is say look if the

temperature is greater than 25 we say it's uh it's hot. But we can also say if the temperature is greater than 30, we say it's very hot. And now what we do in here, if we if we set it up like this, we have an if statement and then another if statement. And let's see, let's actually put this at 24. What will

happen right now? You'll find that currently it will say it's nice weather. But then if we put this to 31 and we run this, you'll find that it's both running is very hot and it's hot. But we in this case we don't want that because we want it to be either one of the decision-m points. So for that Python has something

else and that's called an L if. So here we can chain things together. So it will first check if the temperature is greater than 30 and if that is the case it will print is very hot and then it knows that it can end the loop. So it will not check for this. So what this looks like is now it will say it's very

hot even though this condition is also true. It will not get to that because of how we structured it. So another example over here is uh here another chain and you can also use multiple alifs. you can actually chain them together. So let's say we have a score and if we say if it's uh greater or equal to 90 we say a

excellent here we we get a B here we get a C here it needs improvement. So let me actually copy paste this to see what this looks like. So now with 85 you get a B and if you have a 90 you get excellent. So remember the order of operations right from top to bottom from left to right and if we use an if l if

chain the script will stop once one of the conditions is true and if it gets through everything and there is none of these conditions is true it will always execute the else statement. This is something you have to get used to but this is really the bread and butter of building programs. You take in the data

whatever type of data type it is whe whether it's a number a boolean or a number you combine that into some kind of like variables and you apply some operations and then you want to do stuff with it. If it's this we do that if we get to here then we execute this function. If the escalation is true we

we make sure we get a real human in the loop. Really the fundamental building blocks of how you build systems and how you put something together in a programming language. Now the nice thing is that everything we've learned up until this point can also be re reapplied and combined. Right? So here

when you're using if else statements we can also use the and or and not operators to determine the boolean logic. So similar to how we were first looking at age and license and we're just printing what it was. We can also create if else statements around this and combine them in those two. So just

to showcase that to you, you can come in here and here this will print you can drive and if we put put it to 12. So this is a 12y old we cannot drive. If we want to let the program know that this is not possible we can print this and we will say you cannot drive. Now we run this and it will go and we can put any

type of l if statements in between. And now with if else statements we can even do nested conditions. So we can for example say if has ticket and then we go to the next line but we also say if age greater or equal to 18 we print enjoy the movie and then we do an else statement in here so they have a ticket

but they're not 18. we print needs supervision and then we can come in here all the way to the end and then add another print statement and say please buy a ticket. So now you can see someone's 15 has a ticket they need supervision. Whenever they're 18 they can enjoy the movie. When they don't have a ticket they need

to buy a ticket. Now the next concept that we will cover in the control flow section is the notion of loops where we can repeat code multiple times. So this is often something that you need to do when you're building programs. And for example, let's say you want to do something like this. You want to perform

an operation five times. Instead of writing this out in your program, which is which is really for verbose, we can create a loop around this which is much cleaner and much shorter. The most common way to like do this is using a for loop. So let's give an example of this. And again there is a specific

syntax that we need to understand in here. So let's clear this up. When we do a four, we start with four. That's why it's called a for loop. And we select a counter in here. And this is one of those things in the beginning it's a little bit tricky because this can pretty much be anything. But let's take

i for now. But we can also put x. And we can also put whatever in here. But a common way if you want to create a counter is I because it's really short. And then we say for i in and then in this case we can give it a range. And let's say we give it five. We can then do something like print and then we do

i. So in this case if I run this you will see that we'll print 0 to four in this case. Here is there's a lot going on in here because right now like up until this point you probably were like okay Dave I can follow all of this but this this is not plain English. This is weird. Why does it start with zero?

First of all, one thing to keep in mind is that Python is a uh zero index-based programming language. Meaning that Python starts to count from zero. This is something that we will also encounter later when we're working with lists and indexes. If you want to get the first element, we say we want element zero

instead of element one. That's why you see zero over here. And what we are essentially doing here is we're creating an iteration where we say look for i in range five and range five is a range where we say look we start with zero and then we go to one to two to three to four and then we stop. It's syntax. It's

a notation. It's something you have to get used to. And then we perform an operation. And in this case we use i. So we use the counter uh variable here as well. But we can also for example print hello world and then if we run this it will just simply five times print hello world. But the i refers to the counter

in here. But let's get back to the docs over here and see what's going on over here. So again python starts counting at zero not at one. It's called zero indexing. And you can also count from different starting points. So just this is just a way of repeating things over and over again. We can do it through

numbers by giving a range let's say 1 to six. uh we can even count with steps of two all things that are possible. So let me actually run this over here to give you an example for for uh what that means. So before we had five, right? So we said range five and then we print everything. But we can also say look we

want to go from one to six and then you'll find that it will print 1 to five because it will stop before six. That's just the way it works. And that's one thing like right now you're probably wondering like oh it's a little bit tricky so you start at zero and you put in six but you actually go to five even

I to this date whenever I do four loops um you're always tinkering with this so what you end up doing is you're experimenting with this and you oh wait no I actually want to get to to six so I plug in seven then you correct it and that's the iterative process right that's also what I love about using the

interactive session it's so fast you can select bits and pieces and continue. And then here you have, you can see we add another variable to it. So we say we want to go from zero. We want to start at zero. We want to go to 10, but we want to do it in steps of two. And then what you'll find is that it will go from

0 to 2 to 4 to 6 to 8. So that's something we can also do with the range function. And there are more components to it. But that's just enough for now to understand. Look, if we want to do things over and over and over again, we don't want to do this. That's the takeaway for this section. And that's

all for now. All right. And that brings us to data structures. So how we can store multiple values together. So up until this point, we have stored one value per variable, right? So we were talking about the numbers, we were talking about the strings and the boolean values. But what if you need to

store multiple values? So you want to create a collection and put them together. That's where data structures come in. So these are like containers and they come in the form of lists like a shopping list ordered items. So I want this, this, this, and I also want bananas in there and I also want apples

or a dictionary. These have key value pairs. So it could be like a phone book. So you have a name and there is a number associated to it. So they come in pairs and then you have what is called tupils. These are fixed. So you create them once and you can't really mess with them. So

for example like coordinates and then you have sets. These are a bag of unique items. So you can take a whole lot of information and you just get rid of all the duplicates. So you only have the unique values in there. Those are the common data structures that you'll use within the Python programming language.

So let's start with lists which is actually a really common one. You'll use this all the time. So, we're going to start with the syntax and that is as follows. So, we're going to clear this up and we're going to say my list equals. So, spell that out correctly. My list equals and now here comes the

syntax. We use brackets, square brackets, not the curly brackets. That's for the dictionaries we'll use later. We'll use square brackets. Now, this is the container in which we can start to put stuff. And Python is really flexible. So you can literally view this as some kind of bag or container and we

can dump all types of stuff in it. So remember we had Alice, right? We can dump Alice in here. Alice is a string, but we can also plug in 25. Um we can also say look we have uh h equals 25. And now next to 25 we also actually plug in the h which is now a variable. But we can also plug in actually true. And you

know what? We also uh had the has license uh which in this case is false and now we plug that in and that's all totally fine if we store it in memory and then run it. So let me clear this up to get rid of the errors. So now we have a list all types of different data formats and data types that are in

there. That's the beauty of Python is really flexible uh and it doesn't really care about that. Now whenever we have a list we often want to do something with that. So now we have this list and now we can index this list. So let's say you're working on a problem you have this container and you want to take

Alice out of that list or whatever the that element is. Lists are ordered meaning that how you store it in this way will like Python will remember and through this we can access certain indexes of this list to grab information out of it and we do that in a similar way using the square brackets but now

directly on the list variable itself. So we can now do the square brackets and now we're going to index things. So a couple of minutes ago I explained how Python is a um zero B uses a zerobased index. So it starts at zero. So that means if we want to grab Alice out of here we do a zero and that will give us

Alice. So we could for example say name is equal to my list and then we take the first element. Now that is Alice. Now we can set H equals my list and then we take the second element but we index it with one. And now we get 25 and so on. We can go on and on and on. And also what what you can also do is you can

also say look what if we want the last we want the last item but like what is it? Is it like three four five? Python has a way uh to do this. So this is actually like has license. So we can say let's say the license equals oh look and here actually this is interesting. we get a blue uh highlight over here

meaning that there could be a problem where this is an internal uh variable that Python is using. Now in this case we should be fine. Uh but let's actually like override it with has license. So sometimes you have that for example when you write print that's that's something that we can use inside Python internally

and that's often not how you want to name your variables. So that's just a quick side note. So we can now say my list and I was explaining that how we can get the last element. We can do a minus one. So we can also refers the index. So you can now see we get to has license. We can also do minus2 and that

will give us the true which should be true. And then we can even get minus three. So there are multiple ways like forward or backward to work with the list and to get elements out of it. Now next to grabbing single items that we just saw, we can also take slices. So we can also specify a range using the

colon. Now next to storing information in a list and then grabbing something from it. We can also over overwrite data in a list we can add to it. We can grab from it. We can remove things. So let's walk through some common operators in here. So let's say we have the list and we say my list and now we say look we

have my list and we take the first element in there. We say Alice and we say look now this is Dave. Now if we look at our list you can see Alice has now been updated with Dave. We can also use a list method. Uh in this case is append and we can just add something to it. So let's actually add Alice back to

the list. And what this will do is it will append it. Let's see show you over here. So you can see it has now added Alice to the end of the list. So append is just taking a list as is and then stacking that to the end. And we can also remove stuff. So if we come in here and let's say hey we have my list and we

now do remove and again we want to remove Alice from the list. So Alice is having a hard time with list this list. We're not sure if we want her on or off or whether it's Dave Alice is gone again. So all operations that we can follow. Often in Python there are also multiple ways to accomplish the same

goal. Uh with append uh there is also an insert. So instead of just saying look we want this at the end we can also insert it into a specific index. So coming here again let's see so Alice is from the list again and then we can say look we want to insert and then we say look we want it on index one and we

bring Alice back in there and let's run this. So you can see Alice is back in there. Lots of different ways to think about look what do we what do I want to accomplish? What do I want to do? How do I want to store the data? And then Python likely has something for that for you to accomplish that goal. And similar

to strings, lists also have methods to do even more with it. So we can check how long a list is. We can count, we can index, we can sort, we can reverse. All stuff that you may need to do at some point where you run into an issue and then you'll find, oh, look, Python can actually reverse this list for me. Easy.

But again, these are more these are not so common, I would say, in the real world, especially when you're working on AI cases. Every now and then they pop up, but for now, it's totally fine. Just high level be aware of them. Know that you can do stuff with lists, but it's much more important to understand the

fundamentals, right? What is the list? We can store data into it and we use brackets to do that. That's important. And we index them. That's the most important thing for now. So, let's get into dictionaries. So remember, right, these are key value pairs. So within a list, we simply have a grocery list,

whatever. Alice doesn't have to be related to 25. They're just in the same list, but could be entirely different concepts. A dictionary changes that. A dictionary uses key value pairs. And we do that using the curly brackets. So here we can start to store information in a way where I can say look we have a

person and now I'm going to open up the uh I'm going to create the curly brackets in here. I'm going to do do an enter and I'm going to say hey let's say a person has a name and there comes Alice again and I should put that in quotes over here. So this is the key. So the name is Alice and Alice has an age

and now that is a number. So let's say Alice is 25 and we separate all of the new elements in the dictionary similar to how we did that in the list with a comma. So whenever we go to the next line we do a comma and then we can say look Alice also has um a city and we set that equal to New York. So Alice is 25

lives in New York. Now this becomes a dictionary and what we can do with dictionary is we can look up certain elements in there. So if we have this and we look at the entire dictionary we get everything. But now if we want to for example grab the we want to know how old Alice is in this case what we do is

instead of using indexing with numbers we use the keys to look up the value. So we do that also with square brackets. Again this is a syntax thing. So we define the dictionary with curly brackets but when we want to retrieve information from it we use the square brackets. Something we need to remember.

And now I can plug in the key. So I can say h. And now that will pull the information from the dictionary. It will perform a lookup and we'll say look we got 25. If we do the name we'll get Alice. If we do the city we'll get New York and so on. And similar to lists, we can also update or overwrite information

in the dictionary. So we can also say look person uh name we can just overwrite that and say Dave. So now all of a sudden you can see over here the output now this dictionary contains Dave. And we can also add stuff to the dictionary which is actually quite straightforward. Uh we can just specify

another key. So something that's not in there. So we can for example say we do license equals uh true. And now if we run this you'll find that the name is still Dave. You can see age25 city. And now we have added the license to that as well. And if we want to get rid of that what we can do is we can simply do a

delete. So we do delete person license. And now if we check that you will now find that license is not in here anymore. So those are the same type of operations that you can do with a list and within a dictionary. And when to use which one is something you have to get a feel for when you're are when you're

working with Python, when you're programming in general, there are often infinite ways to solve the same problem. So you could very well solve problems by just using list and storing everything in there. But sometimes it's much easier to have key value pairs where if you want to look up something, you don't

have to figure out look what was the index of this list and then need to figure out where was it. You simply know, oh, I stored it at the H uh I sorted at the H key. So if I want to know the H, we just need to plug in that. This is all something you'll get a feel for as you get more experienced and

more exposure to working with the Python programming language. All right. And lastly, dictionary also have methods. So we can use the keys, we can get the values, we can can get the items. So all different ways of accessing the information that's available within the dictionary. This is a nice exercise to

try for yourself and see how they work. Okay, then let's get into tupils and then finally in sets. So these are data structures that actually in the wild you don't really use a lot, but it's good to know how they work just so when you encounter them. So a pupil is immutable. So remember right with the list and the

dictionary I saw look we can create it and then look we can just override the name we can remove Alice all of that. Tupils are immutable. So the the idea of a tupil is you want to create it and the program should never touch that. So for example when you have a coordinate or an RGB color and just when you want to

adjust it you just write create a new one because the coordinate is not going to change and tupils are specified with parenthesis. So remember we had lists square brackets we had dictionaries curly brackets now we have tupils parenthesis okay so tupils go in either in pairs or you can add more to it. So

we can have a point and uh we could have three and five and we have colors. So let's actually plug this in and get a feel for what this is like. So we have an empty pupil. There's nothing in there. We have a point which is three and five and then we have the colors in here. So what I can now do is let's say

colors and I want to get the first element in there. So this works similar to how we're working with the list, right? It's very similar uh but it's just in a way where look if we now say look this is now blue. this will get an error because if this were a list, this would be totally acceptable. But now

tupil object does not support item assignment. That's what the error says because that's one of the properties of why you want to use a tupil. So other than that, it's very similar to a list and we can do all the same things, right? We can do get items, we can use zero, we can do minus one, we can do

slicing. That's all you need to know for now. So let's get into sets. final data structure of really the Python basics, all the really most fundamental Lego blocks. And a set is a way to create unique values to make sure that whenever we're working with a collection, there are no duplicates in there. There are

two ways to create sets. We can use the set notation over here. Or we can use curly brackets, but then not assigning the key value pairs because otherwise it would be a dictionary. So let's quickly go through this because you just need to see it at this point rather than like fully understanding everything that's

going on. So we can create an empty set. So there's nothing in here and then we could later add things to it. But we can also set it with values. Both ways work. So here let's say we have a set of numbers 1 2 3 4 5. So these are the numbers. So this is now a set even though we use curly braces because we

don't do the assignment with uh the colon and using uh strings in there. It's a set. Now we can also do it like this. So again in a similar way we use set parenthesis and then we plug the list in there. That also works. Now we can use it to dduplicate items because if you don't do that like if you don't

have or don't intend to do that like you could just as well use a list. There's no uh there's no point for that. So let's say we have the scores over here. So notice how 90 appears in here two times. So first this is a list. See we're using square brackets. So if I store this in memory and let me actually

switch this over here so you can see it. If I store this in memory and print it, you can see uh this is the list. But now we can create unique scores by using the set notation and we plug that in here and you can see oh it's actually like it was 90 and 85. It's also twice in there.

I didn't even notice that. So now you can see it get it gets rid of the duplicate values and now we can store that and now our unique scores become just that and we can do that exactly the same over here. Apple, banana, orange. These are the fruits but now if we add banana one more time it works in exactly

the same way. Oh, I missed a quote over here. So now fruits is still apple, banana, orange even though banana is in there two times. So that's really what you should know about sets and the basic operations. We can remove, we can discard, we can check things, but it's to dduplicate collections. All right,

and that brings you to the end of the Python basics section. So we covered almost all of the very fundamental building blocks that you need to understand about the Python programming language. Data types, data structures, operators, how you can combine them. And you should now get a feel for what it's

like to write simple Python functions, right? You should be getting comfortable with either executing code through the terminal terminal or see why the Jupyter interactor session is so nice to work with and how you can quickly explore what the data is, check if you made any errors and course correct. So with this

fundamental understanding out of the way right now, the next section, building programs, is all about how we can actually use all of these building blocks and create longer scripts instead of just isolated lines that we've been doing and how to piece things together. So it starts to look more and more and

more like we're actually building something and automating something. We're getting there. You're crushing it. And right now, I still understand this is new. These concepts are very abstract. They're isolated. You don't have to remember all of this. This is just the first exposure and it will get

better over time. And now this would be another great time to take a quick break. Maybe grab another fresh cup of coffee or your favorite beverage and then we'll get into the building programs section. All right, so let's dive into building programs. I also took a fresh cup of coffee here. And in

building programs, we are going to cover here on the left side. We can see we're going to get into functions, external tools, practical tips to use, how you use Python in the real world, error handling, and then we get into classes. So, this is really where you'll get to see Python come to life in action, and

we can actually start to do stuff with the language. So, let's dive into functions, which are used to create reusable blocks of code, so we don't have to repeat ourselves. You can think of a function like a recipe. you can follow multiple times. a machine that takes input and produces output or a

named shortcut for for example complex operations and before we already saw that we could use loops right so when we did the five times print hello world that's a little bit redundant and we don't want to do that so we created the loop to do that but let's say we have more complex logic so it's not just a

oneline print statement but there are actually calculations there steps printing steps maybe we need to get some information manipulate some information and every time something happens within in our system, we need to do that. That's where functions come into place where we can define it once and then

later within our code, we can simply call that function and we can now use that functionality. So we don't have to write the same thing over and over again. And you've actually already been using some of Python's built-in function. So for example the print statement that we use all the time or

the length that we use to um count the items or the length of an array we have also used that already. So those are Python built-in functions and within functions we are right now we're going to cover three main things. We're going to I'm going to teach you how you can define functions. Then we're going to

talk about parameters. So these are things you put in the functions to control the inputs and the outputs and then returning the values. So this is what the output of the function will be. All right. So let's start with defining functions. And for this I'm going to come over here to Visual Studio Code and

we're going to start with a new fresh clean slate here in hello.py. So as with anything with any new concept we're going to start with some syntax, right? Because first there are some rules that we need to understand before we can actually get into the functionality. Now every function in Python starts with

defaf from definition meaning we're going to define a function then followed by a space and then we're going to write the name of the function. This can be literally anything. You can put anything here. Now as a rule of thumb you want the function to be descriptive of what it does. So let's start with a simple

greeting function to create a print statement. And what you then want to do after the name of the function, you need parenthesis opening and closing parenthesis and then a colon. Again, this is all syntax. You need to see it once and then you can quickly refer to it. For now, this is all we need. And

then we can hit enter. And now we get into the function. So we have now specified our function over here. And here in here with the tabs or four spaces, we can actually put stuff in here. So we can for example write a print statement and say hello. All right. And now let's have a look at what

happens when we run this. So you can see right here we we load the function into memory but there's no output. We don't see anything here. And the same would be true if we run it in the terminal. You can see it just tries to run the script but there's no output. It just mentioned

that it runs the file. So that is the case because when you define a function it is simply a placeholder for that logic. But when you want to actually use a function, we need to specifically tell Python to do that. So what we can do is we can come over to a new line over here and type in greet and then we do opening

and closing parenthesis. And now this is actually where we would call the function. So now if I one more time open this up. Now if I do greet you can see that it executes the function and that it outputs the print statement over here. Similar if I do a copy paste over here uh and I can do hello again and I

store this into memory and then do greet. You can see now we've changed our function and then now when we call the function now it prints this. So that was your first function. So the important thing to remember is the syntax. We start with defaf function name opening and closing parenthesis and then we do

the colon. Then you can add your code here. Make sure it's indented. And then if you don't want to return something, you don't have to put in this pass over here. But you can also do it for clarity. So normally functions will often return something. And this pass putting this pass over here is simply a

kind of like a readable way for humans to say look this function doesn't return anything. I in the next sections I'll show you how we can return stuff. But you can see it doesn't change anything. So you can also just get rid of this and it will be exactly the same. but Python accepts it. So those are the key parts

and then some tips on naming functions. So like I've said, you want functions, you want functions to be descriptive of what they're doing, right? And there's also there al there are also some style rules to this similar to how we talked about there are style rules to variables, right? We use a similar setup

over here. So we use lowercase letters and whenever there's a space, we use an underscore. So if we want to calculate some kind of total, we do calculate underscore total. We want to send an email, send underscore email, no capital letters. So we don't want to do uh we don't want to use capital letters in

here. Those are reserved for classes which we will cover later. But remember these are styling styling guidelines. So it will work perfectly fine. You won't get an error. But other developers will look at you and they will see that you're a beginner and we don't want that, right? So then calling the

functions this is what I already showed you right. So let let me actually copy paste this example over here to see we can also call uh functions multiple times. So that's the nice thing about a function. So here we have say goodbye we can do it once and now if we do want to do it one more time in our script we can

simply just refer and just call the function instead of having to do it over and over again. And now what this means whenever you run your entire script so everything runs you can see that all of the logic here is executed. by three times. And beyond just simple print statements, we can really do anything

with in a function. So we can also come back to some of the logic we already tested before and we can input if else statements. And the most important thing here to keep in mind is the indentation and how you structure how you structure these functions, right? So let me walk you through it. So when we create the

function, we do defaf and we do the check weather. And you can also see over here like how your ID how the code editor is helping with this. So now this this is how we specify the function. Now we do an indent. Now if we want to check what if we want to uh include an if statement we do if and then let's say uh

temp greater than 25. We for example print and we say it's hot. And now you can see these squiggly lines under here under temperature. And that is because right now Python doesn't know what temperature is. And that's because we haven't specified it yet. So you want to store that over here and say look temperature

is 16. If temperature is greater than 25 print it's hot. Then we go in here and then I do a shift tab to go back to this line. I do an else. I do another enter. Our IDE will cover the indentation and otherwise print it's nice weather. So this is why it's also good to like I've said beyond just copy and pasting the

examples over here really writing it out because if you just do copy paste and you run it everything will run but it's those nitty-gritty things where like look how how does this work? Should I have it like this or have do I have it on this line? And you can immediately tell that your IDE will tell you like

something's off. And this is how you build the like the the muscle memory and the the uh the skill really to look at Python code and think about okay look this is a function we have if else statements this is how it should be structured. So now if we do this remember if we run this what happens

nothing correctly because we haven't called the function yet. So now I go to the other line over here. I go all the way to the back all the way really to the beginning. So no indentation and I'm going to do the check weather. I hit enter to autocomplete. So that's also something you'll notice, right? So I do

check and now my IDE already says look check weather is a function that I have over here. So now I can just press enter and it will autocomplete that. So that's also one of those things where you need to you need to get your hands on the keyboard. You need to be able to type and then you'll find all kinds of

interesting things that your IDE will show you. So you'll find that as I go through all of these examples, I'll also explain more and more of these things behind the scenes. So now we have to check weather over here. We can put it into memory. Check the weather. So it's nice weather. I can come over here.

Let's say let's make it 30. Store this. Check weather. It's hot. Okay, that's our function to check the weather. All right. Okay. So let's come back over here. You can check out some common mistakes. If uh things don't go wrong, things is like you forget the uh parenthesis. That's a that's a big one.

You forget the colon at the end. So do greet no colon. All beginner mistakes that you'll uh run into or the bad indentation. So it's not formatted correctly. All right. So let's now let's continue on this and let's talk about parameters. So parameters work with functions to make them dynamic. Right?

So if I come back to this example. So right now like this is hardcoded and hardcoded means whenever this script runs it will always be this. I can do this all the time. I can do check weather, check weather, check weather. It will always be hot and this will never change. That's because there are

no parameters that we can programmatically or dynamically change. So that's where parameters come in. You can now see that we can also add parameters in here and parameters go in between the parenthesis. So over here you can see we have the greet function but then we plug in the name over here.

Now we can use that variable name in the function itself. And then when we call the function we can plug in that parameter and it will use that it will use that data within the function. Okay. So let's have a look at how this works. Again we have our simple function over here. So let's do another one. So we do

greet. So dev greet this is all the same and then we do the parenthesis. And now what we do is we do name and then we do a colon. So now this function takes name as a parameter. And what we can now do is we do print and we create a string. we say hello and then remember if we wanted to to use variables within

strings, do you remember what it was? It was called using an f string. So we put a little f before the string and then we could use the curly brackets in here to plug in a parameter. So now when we have this function and we go to greet, what we can do is we can now say name equals

and let's say we can put in Dave. So we save this and we do greet and you'll find that it says hello Dave but we can also do this one more time and we can do hello Alice. So this is a way for us this is a really this is a key concept about working with function because this is something you'll do all the time

where when you're building programs you think about look what logic do I want to implement what data what information is is coming at me and how do I want to use that information within my function so now we've made a dynamic script that we can change and one thing to uh remember

here is that for Python it doesn't matter in this case if I specifically say name equals Dave or I just do greet Dave because how this works is you can also have multiple parameters and it will just follow the order of operations. So let me show you what I mean with that. So I can also for

example let's let's do let's do last name first name last name and then we say look we have a first name in here and then I just do let's see I do space in here and then we do last name and so now we have two parameters in here that we can insert. And now what you'll find is if I do this and if I run this

function we'll get an error because it says look greed. Let me actually move me to the side. So you can see now greed is missing one required positional argument last name. So Python now understands look in this function you actually need two parameters and you only gave one. So if we now plug in my last name over here

you can see that right now this is all uh correct and now we can see hello Dave ablar. So now it's all good and you'll see that you actually don't have to specify first name last name because Python understands look this is the order of operation. First we do the first name and then we do the last name.

So if I swap this around and do it like this and I agreed it will be reverse. It will it will take my last name and we'll plug it in the first name. So I what I always uh like to do I always like to be explicit with this and really say look first name equals Dave and then I put the last name in here. So you don't have

to do this. Python will also work without but especially if you're working with multiple functions right now you can clearly see look this function is greed and I plug in the first name and the last name. So you add a little bit more code to it but it helps for readability. So now when I plug this in

and I greet it, you'll find that it works correctly. And now what's also interesting now we can also like if you want to for whatever reason you can also swap it around. So now the order doesn't matter because we are explicit about it. So now if I run this even though the order is in reverse it still says my

name correctly over here because we mapped them to the correct parameters over here. And now functions can also have default parameters. So what you can do over here whenever you specify the function let's say first name let's say you can put an equal sign in here and let's say we do John and then last name.

So oh this is another interesting thing you can specify default values in here. Now you'll see that we get red squiggly lines in here and that means that here's an error. So this is another syntax thing. Whenever you want to specify default values, meaning that right now uh I for example don't have to put in a

first name and then it will if there's no first name, it will default to John. But there's an order to things. So you need to uh you need to set the parameters that don't have a default value first and then you set the ones that have default values. So now it's just like it's just like swapping things

around in different order. The functionality is still the same but this is just like what Python expects. So now if I store this function now let's see I can uh come in here and look now I can actually run this function and I only need to plug in the last name and it won't give me it won't give me an error

because now it will simply say look okay first name is not there in that case I always take John and let's see we can do something similar for the last name and now because this is now also has a default value we can swap it around again just for the order of things. And now I don't actually have to plug

anything into my function and I can just run it and it will run with the default values of John Doe. But I can simply override that and say look I want to greet it with Dave and vice versa. You can do it with last name, first name, both. So that is a way to work with parameters. You can plug them in. You

can give them default values. You can change them to make your programs dynamic. Okay. So we've already seen that you can just work with multiple parameters. So you can add as much information as you want there. So let me quickly show you this example about calculator. So here you can see we have

a function calculate total. We take the price, the tax rate and the discount. And now instead of doing simple print statements, we're going to apply some math. Right? So we we first calculate the tax by u multiplying the price with a tax rate. Then we have a final price. So we're storing v variables inside this

function over here and then we print the final price using an fstring and then you can see over here order matters. So let's see because right now we are not specifying the uh names right we already saw this then order matters if we are specific about this that's why I always recommend to do that you cannot make

that mistake so you'll always find that it's very clear that the discount is this this is the tax rate and this is the price so that's why I always recommend using these keyword arguments that you can see over here right you specify the function and then when you use them just make it explicit. Say the

city is this instead of just like relying on the order uh of operations. Now, one more other thing that I want to show you here when it comes to functions is the notion of global versus local variables within Python. This is a common mistake and this can be really frustrating in the beginning. But

whenever so by now you know you when you uh run a Python file, it goes from top to bottom, from left to right. But there is also a notion as to when we are inside a function or in a class for Python that information now becomes locally and I'll show you in a bit what that means but it essentially means that

you can use that information within the function and within the function Python understands what it is but outside of the function we cannot use it. Let me show you an example. So let's take the calculate the calculate total over here. So we have this function and over here let's even make it simpler by setting by

hard coding the price over here. So or let's say we we just take the price and we get rid of the tax and the discount. So we set the tax rate we hardcode it. So we set that to 8 and then we set the discount to 10. And actually let's make it even more explicit. So we put the tax rate here.

So we plug that and then we can put the text right here and then we say the discount is 10 and then we put that here. So now we can see and you can also see how I can play with this. I can add a comment here. So we can for example so these are the default values and then over here we are going to do the

calculation. So and then we do print final answer final price. Okay. So now we have made the function simpler in a way where it only takes the price as an input and we can calculate this and you can see this show up over here. So now what happens if we for example are in another part of our script later down

the line and we want to continue. So we first made one calculation and now we want to maybe add something to it and we want to use the discount one more time. So if we for example now say look okay I want to use that discount again because we we set it to 10 right uh discount is 10 over here you see if I just type in

discount in here it will give us the yellow squiggly line saying discount is not defined so when I run this it will get an error even though this right now is all stored in memory it's in the same file discount is not available so you can see I'll actually move that discount is not available and that is because

this is the difference between local and global variables. Whatever is inside a function is considered locally in Python and then outside the function we cannot use that. So there is an order to things. So if I for example now set over here at the top I set discount is let's say 20. I run this you'll find that we

set the discount to 20. Now we'll get inside the function and it will perform the calculation. you you'll still see that the total is the same. So we get the same answer. We get the 98 and that's because inside this function, Python prioritizes the variable that you have over here. So even though first we

say discount is is 10 because we go from top to bottom and from left to right, it will overwrite the 10 over here. Then it will perform here the calculation using all of the information in here. But then later when outside the function we refer to the discount, it is still 20. And

this is really just one of those examples that you need to run into this a couple of times in the real world and think about like, oh look, I thought discount was 10, right? Why is it 20 right now? And then why is it 20 right now? And they see, oh wait, it's a global variable over here and here is

the local variable. Now, um I've shown you that if you don't have a global variable and you just have local variables in the function and you try to access it, it won't work. But here's the thing, it works the other way around. So within functions, we can use global variables. So if I specify the discount

outside of the function, we can use that discount in here and Python will know, look, we have a global variable. So that's one level higher, it overrides it and we can use that inside a function. Now, this is not common, but it can uh it works. And why I said it's not common because typically you want to be very

specific about this. and then still add the discount as a parameter because otherwise information can get lost meaning that if I specify the discount over here and then let's see I have the function and now we calculate the total price you can see that the output is still the same so this discount is

referring to what's specified over here but now when you're working on real projects you often have multiple files multiple functions and now someone's working on this and you see this function over here and someone decides to get rid of this now this function doesn't work anymore because now uh

let's see if I get rid of this. Now it says look there's no discount over here. So adding that and making that specific in this function is best practice in that case so that you always know look whenever you need to calculate the total we also need to plug in that discount specifically over here and it doesn't

matter where we get it from but this is the place and that's how you don't forget it that it needs to be in there. So that was a little bit of playing with global local variables. You get some exposure to what it's like to work with the function to input the parameters and then how to call the function. And

really it's about practice here. You need to see multiple examples. So later on when we're going to the practical Python in this session, we're going to actually do some stuff because I'm fully aware and this is some of the things that like really bothered me when I was learning Python in the beginning. You

always see these like cookie cutter examples. So like look I can yes I can print someone's name but what what is actually the point of that right? So bear with me we need those fundamental building blocks. So then here I'm literally going to show you like how you can take a CSV file import it do

calculations and then write it back to a file and that's really where things will start to click and we're going to reuse these building blocks again but we need to be step by step. Okay so then the final section in here of functions is returning values. So up until this point we created functions that just do

something and then either just print something or do nothing. Functions can also return something and we do that with the return syntax over here. So let's dive into some examples. Okay. So let's say we have the simple function and we do a print and we take a and b as parameters and we just in this case we

just print a and b. So this is now what we saw before very simple function we don't return anything. So now if we do add print and we call this and we plug in a= 5 and let's say b= 10. Okay, wait. We can for example do let's actually do plus. Okay, there we go. So now you can see we run this function and it just

does a print statement but it just shows up in the terminal but now we cannot access that 15. It's like it's gone right now. It just it was a one-time print but now we there's nothing. Let's say we want to add something else to it. There's no way to to reference that 15 or a variable where that is stored in.

So that where that's where return comes in. So when we want to perform an operation and we also want to like store that and do something with it. So then what do you do? You add a return. So we do a return. We do add and we do a return. So we do this. We do the same stuff. So we do a and b. We plug that in

and let's see colon. And now what we can do is instead of a print we do a return and then we say a and then we do plus b. If we now run this and we say add return and we call that function. The thing is in the terminal if I run this over here let's see oh sorry I should plug in the

variables over here let's see we will also see 15 but there is a difference and that is when we do the at print so we just print it it will like printing is just show showing it but we cannot do anything with that later whereas returning it it is actually returning it and we can capture and we can store that

information and the way we do that is simply by saying look we have our function and it outputs something and we store that into a variable. So now what we can do now if we run this now you'll see we'll we'll just run this line and you won't see the 15 show up here because it's stored in result and now

result is something that we can use and we can do whatever with that. So now we can do + 50, we can do + 20 and that information is stored. And here it's also important to let's see to give a a quick distinction between the interactive session that we use all the time and running it in the terminal uh

when programs run in the background for example because because when I for example comment this out, I select something and I do command forward slash or on Windows uh control slash you can comment out entire blocks very easy. This helps if you want to run your program without running this. For

example, if I now run it in the terminal, let's see. So, we do run in dedicated terminal. You can see this show up. Now, you can see that it will it will print the 15 out over here. So, you'll see that if we close this out and now this and I encourage encourage you to follow along with this and also like

play with like commenting these blocks out and then moving quickly between them. Now, if we run this, you'll see that we run it, there's no 15. So this is a difference between the interactive session and the terminal if you do it in the interactive session. Even though it's not like printing it, we can still

see the the output. But that's just something that you have to keep in mind. But there's there is under the hood there's a difference because this 15 is something that we that we can use and this is print statement that that just shows up because let me show you if I now do so we have the result you saw we

can store that right we have that 15 but if we do that over here so we say if the add print so we do print results equals we can save the output we will see the 15 but now when we do print result it's empty there's nothing here so little tiny difference but something in beginning that you need to get used to.

Okay. And so with that we can perform all kinds of calculations. So let's take the following example over here. Let's copy paste it. So here we have a function to calculate the area. So it takes as an argument the width and the height and then we calculate the area by multiplying it and then we return the

area. So we can also store in between variables. We can expand on them do calculations and then return the variable. So we don't specifically have to do the return statement here. Whereas this would also work. It would be exactly the same. But this is a little bit easier to also help you as a

programmer think through your program, right? What's the goal? First, we want to calculate the area. How do we do that? Width time height. Okay. And the area is the stuff that we want to return. So if I run this and I calculate the area, we can print the room size and it's 120 square ft. And we can simply

for example come in here and let's say you know we want to er uh we want to add a margin of error. So we want to say look area is area and then we do it times 1 let's see let's add a 5% margin and then you'll find that it's bigger and these returned values we can use them later. So if I take this example over here. So

let's say we have a very simple function to double a number. We can have a result which is now uh 10 because we input five and the function doubles it number times two. We get that result and then we can use it in another expression. So let's say we have the total we do double five

double3 and then we get 16. So you can see how we can now start to combine things right. We take this function and we use it just in an expression. So instead of just first storing the results we look double five that will output 10 and double three will output six and we can simply combine that right

like this will be 10 we store it in total and now we have total and we can print this over here and we can also use it in a condition. So we can say look if double 7 is bigger than 10 we say it's a big number. So the like this is this this can get a little bit tricky to to work with but that's why I why I love

the interactive session because you can literally look at okay what does double 7 do by selecting this using the uh arrow command uh arrow on your keyboard and shift and I can look this is 14 so now I do if double 7 which is 14 is greater than 10 it's a big number so now if I run this it will say big number but

if I say let's say we do three and I run this it will not do anything. And within functions, we can also return multiple values similar to how we could also input multiple parameters, right? So, let's do a let's do a just a simple function just as an example. Uh we define it and then say look, we have a

we have our numbers. Let's say we have our numbers which is a list. We do 1 2 3 4 5. You should actually do some spaces in here for clarity. So we have the numbers in here and then what we want to return or let's say first we do we do the first number and that is going to be our we have our numbers and then

remember this is a list right and we can index that by using the uh square brackets and then we do index zero this refers to the one so this is the first number and then let's say we do the last number and that is going to be uh let's see we take that same thing numbers and then we do minus one and then what we

can do is we can return first number and then we do a comma. So this is syntax again. So it's not end or n. We do a comma to say look we want to return the first number and we want to return the last number. And then what we can do is we can for example let's say if we have this here in memory we can call our

simple uh function with doesn't take any input parameters right now. And then if we want to store that we could for example say first number and then comma again last number and we can capture that. So now if we run this you'll find that we have first number one last number is five. And the thing to keep in

mind here is that the variables over here do not have to be the same as what we put over here. So we could for example just as well do f and l and it would also work. So now we have if we we do it via print statement we could print our f which is one or we could just look at f over here is one and in a similar

fashion our l is five. So that's how you return multiple values from a function. And that also wraps up the section here on functions where the most important thing to keep in mind here is that when you're using functions, if you use a print statement, it just displays it. When you want to return something, which

is what you often want to do in the real world, use the return. And in the beginning, you'll make a lot of mistakes with the syntax. You have to do it a couple of times before it really clicks. def function name colon indentation it will get more and more familiar. Okay, so with that let's dive into the next

section se section called external tools. So here we are going to get into one of Python's core tracks where we can actually use a lot of like out ofthe-box tools that other people have created for us to make our life as a programmer much more fun and way easier. So, we already talked about packages, right? The pip

install things. In the beginning, I showed you the request library. So, now we're going to dive a little bit deeper into that and show you a little bit more examples. So, why Python is so awesome and why I also like back in university. So, this is 10 years ago when I when it really start to click for me working

with Python was beyond all of the boring stuff that they showed in the lectures like what I show you right now. I know this is boring, right? Writing a function, like doing a print statement.

How videos are chosen here

Every video on Helicopterstour.com is hand-picked and reviewed by Justin — nothing is added automatically. Each one gets an original written guide and an honest rating: ⭐ 1 out of 2 means a good video worth your time, and ⭐⭐ 2 out of 2 means a great one we would recommend to anyone. The videos belong to their creators — every page links back to the original channel so you can subscribe and support them.

Contact us

Get new videos in your inbox

A short email when we publish something new. No spam — unsubscribe anytime.