 Hi everyone, welcome to another Career Foundry event this evening, where we are joined once again by the YouTube sensation that is Alex the Analyst and if you haven't, check out Alex's YouTube channel over on YouTube, Alex the Analyst. Every time that I do a webinar with Alex, I think he gets about 50,000 more subscribers, so do check that out. And then we've got a big crowd this evening and we're streaming on lots of different platforms. I can already see some people joining. So whilst people are joining, maybe just if you're watching on Big Marker, just write why you're interested in data analytics and especially Python. So tonight we're all about Python and we're also streaming on YouTube and LinkedIn. So welcome everybody. Let me just briefly explain who Career Foundry is. So I'm William, events and communications lead here at Career Foundry and Career Foundry is the online school for your career change into tech. So we take you from complete beginner to job ready professional in data analytics and help you land that first job in the field. If you've got any questions about Career Foundry on YouTube, we've put a book of course in the description below so you can book a call with a program advisor. If you've got any questions about our curriculum, if you've got any questions about the dual mentorship model or our job guarantee, do book a call with a program advisor. But this evening it's all about Python and I know that Alex has also bought his audience this evening and they are very, very engaged. So welcome all of Alex's audience and for anyone who's watching from Career Foundry, as I said at the beginning of the webinar, do check out Alex's YouTube channel, Alex the Analyst for some fantastic data analytics content. One thing to note about this webinar is it is going to be recorded. So we are recording this webinar for everybody watching on Big Marker. We will be sending around the recording via email tomorrow. So if you do miss anything because Alex is probably going to be moving quite fast, you will get a recording tomorrow. And do remember if you're watching on YouTube, you can also rewatch the video again in case you missed anything. We are putting this ambitious, you know, it is an hour session, we are going to be quite ambitious, we are going to be moving fast, but you will get a recording tomorrow. At the end of this workshop as well, we're going to be doing a live Q&A. So if you've got any questions, I've got some team over on YouTube. We've also got a team on LinkedIn too, so do drop your questions and I'll be asking all of those questions to Alex at the very end. That's all from me. Alex, take over and I'll see you again at the end for the live Q&A. Thank you so much for joining us this evening. Thank you. Thank you. All right. Yeah, like he said, we have a small amount of time. I say small because I'll try to keep it like 45 minutes ish. So we have Q&A time at the end. I have a ton of stuff prepared. I don't know if we're going to get to all of it, but I'm going to try my best. If you don't know who I am, I'm Alex Freberg, better known as Alex the Analyst on YouTube. I'm the founder and CEO of Analyst Builder and I have my own data consulting analytics called Alex Analytics. Besides that, before I was a data analyst and an analytics manager, I'm looking down here, but I should be looking up here. I just kept my computer separate from my webcam so I could type better because we're doing a lot of live coding this time. We have a lot to go through. Let me see if I have anything on there's no next slide. I'm going to share my screen and literally what we're going to do is go from the very basics of Python, very, very, very basics. I'm imagining you've never heard of Python before in essence and I'll start walking through it. Now, that's an exaggeration. I hope you know at least a little bit about what Python is because we're only doing a lot of hands-on live coding. I'll really quickly tell you what we're going to be working on and then we'll start working on it and we'll get through as much as possible. Now, I'm going to share my screen. If it's working, I will be told in the background that this is working. Let me share this and if it is working, please let me know. Alex, it is working. Excellent, excellent, excellent. I'm going to, we're going to get going because, again, have a lot to cover. Now, this is what we're calling this Python in one hour but I'm going to zoom out real quick. We're going to be going through variables and data types, statements and operators. I prefilled a few things just to save time. We'll be walking through functions and then we'll be diving into data analytics specific Python things, like some popular packages and libraries, mostly focused with Pandas, although I've been diving into Polars myself lately. I really enjoyed it. Pandas, Polars, Seaborn, NumPy, Matplotlib, we'll be manipulating data in files and then data visualization and web scraping. As you can see, we have a ton of things that we're going to be working on. Let me scroll back up to the top. We're going to start with the very basics and work our way up because that foundational knowledge is pretty important. Now, at a super high level, really quick, just if you've never heard of what Python is, it is a programming language where it's really made to be super user-friendly. The syntax is pretty simple. I remember when I was first learning it, though, it took me like four months to learn a lot of what I'm showing you today because it did not click with me. I say it's simple comparatively. Now that I've used other programming languages, I find it to be one of the more easier ones to understand. It's super popular with data analytics. I know a ton of data analysts who use it all the time. We're going to walk through what a lot of these things are, how to use it. I'll go through a lot of examples. I have another screen over here where I might be referencing because, again, we have a lot to cover. Let's not waste any more time, although I don't feel like I'm wasting time, but let's not waste any time. Let's start going hands-on and start taking a look at this. Let me get this in case I need any extra cells or anything like that. The first thing I want to talk about is variables and data types. Now, data has to be stored in some way, whether that's in memory or in memory through a variable. All a variable is, we're going to say x is equal to a number. That example up there is 22. Now, 22 is data. It's just a numeric data type. We'll get into the data types a little bit more in just a second. The variable is what stores it and what's great about this is oftentimes it isn't really a simple number that you're storing. You're storing really complex things and they're very large. You can store it into just one little tiny variable there. If we say x is equal to 22, it's going to store that x in a specific location in memory. Then when you call it later, if we say print x or we can even just say x, but we say print x, we'll get 22. It's going to search in that memory and pick it out. That's what a variable is and they're fantastic for that. Now, what's really great about variables is Python automatically stores data types for you just automatically, which is really neat. We can see that if we do type of x, that this data type, which we never said that it was a specific data type, it's automatically going to be an integer. It already knows it's a number before anything. Let me give a few more of these real quick because I feel like I'm going to need these. Let's move this down. Now, when we're doing this, oftentimes we will want to use other data types. When we're using variables, I don't only use numeric. Most of the time I'm working with things lists or I'm working with things like dictionaries. These are very different data types. There's actually a lot of very popular data types that we're going to take a look at. I'm just going to scroll down here. The first one is the one that you just saw, which is just a number. I'm going to do 222. This is an integer. Let's say I'm going to copy this. I want to type a string, say I like Python. If I run that, it's going to give us a string. Now, I have two types in here. It's only going to give me the most recent one. I'm just going to keep it like this so you can see them all. In fact, let's zoom in just a little bit better as well. Now, the next data type is called Boolean. Boolean is a really interesting data type. It's interesting because there's only two values. It's either true or it's false. A string could be anything you could ever imagine. A number could be anything numeric. A Boolean is something like false or true. If I run this, it's going to say Boolean. It's just stating whether something is true or false. If I said, and this isn't planned, but just as an example, if I say 10 is equal to 20 and I run this, it's going to give us a Boolean output of false. That's all Boolean really is. Let's come down here. Take a look at the next one. The next several ones are a little bit more complex because they store multiple values. For this first one, it's a list. Now, we can signify a list by using these brackets right here on the front and the back. They can store almost any data type you could ever want, like a number. I separate these values with a comma. It's storing two separate values. I'm doing one comma false. Another list where I do 1, 2, 3. I could even do a string. I like this. If I run this, it's going to show that this is a list. Let's move on to the next one. There are some different types that store values, but they behave a little bit differently. You see lists can store anything. You can change it. You can alter it. You can do anything. Lists are amazing. I probably use lists the most out of any data type, but there are other data types that store very similar data, but just behave a little bit differently. One of these is a tuple. A tuple can also store different types of values. I'll run this. It's going to be a tuple. The only difference is, and I'm not going to demonstrate because this would take a little bit of time, I can't go back and alter a tuple. A tuple, once you create it, stays a tuple. If you want to change it, you essentially have to create a new tuple with these altered values inside of it. That's what a tuple is. The next one we're going to take a look at is a set. A set can also store values, but it's only going to store the unique values. For example, and to do this, we'll do a bracket. We have these squiggly brackets. I think they're called curly braces, but I call them squiggly brackets. If we do one, two, three, three, two, one, four, five, and six. If we just run this as is, it shows that this is a set. But if I try to print this off, you'll notice we don't have all these duplicates. One, two, three, three, two, one. It's only going to show one of these. It's only going to show the unique values inside of it. That is something unique to sets. Now, the very last one I'm going to show you is a dictionary. Now, dictionaries are also really great. These are probably out of all of these, the most unique because they don't really look like any of the other ones, except for they also have squiggly brackets. It's going to be pretty easy to tell if it's a set or if it's a dictionary based off of how it looks visually because dictionaries have something called a key value pair. If I just come in here and I say name, that's going to be my key. That key is going to store a value. I can come in here and I can say Alex. Then I can do a different one. I can do flavors. This will be my favorite flavor of ice cream. This will be mint chocolate chip. If I run this, it's going to show that this is a dictionary. Now, what I can do is I can save this, and I'm actually going to come down here really quick. Oops. I just went way too fast. I was trying to enter and I was hitting shift enter. I'm going to save this to a variable. I'm just going to call this data. I'm going to declare this as a variable like we were looking at before. This dictionary is going to get stored inside of this data variable. I'm going to run this. In order to extract the data, we have a few keywords. We can do data.values. That's going to be these values right here. We can run this. I was going to say these dictionary values are Alex and mint chocolate chip. The next ones that we can do, I'll write down here, are the keys. These are our keys that we're using. Here and right here. If you run this, our dictionary keys are name and flavors. Then we can take all of it out at one time by doing items. Now we're taking all of these individual values or key value pairs, name and Alex and flavors and mint chocolate chip. Now I can talk about data types literally for hours because this is just scratching a little bit of the surface. I have a lot more interesting things I like to get to. We're going to keep going. I'm going to come down here to a statement and an operator. This right here is not necessarily all of the statements that we're going to be working with. This is one of them. What this is, is this is a while loop. We're going to look at if statements, for loops and while loops. These are logical conditions that you can set to control the flow of logic. If you've ever used SQL, it's like a case statement or can be with the if statements. If you've ever used something like Excel, there's a lot of things in there as well like if statements that control that flow of logic or they're called if functions. In here, when we look at this in just a little bit, we'll have this condition. If that condition is true, we'll run a block of code. If that condition is false, we will go past that. We'll go on to the next code underneath it. They're these levels that we'll have. We'll get to this one in a little bit. I wanted you to get in the idea of if it's true or false. If something is true, a condition is met. If it's false, a condition is not met. We control that flow of logic. Let's come right down here. What we're going to do is we're going to create and categorize this price really quickly. We're going to do this first with an if statement. Then we'll get down to for loops. Then we'll get down to while loops, which was our diagram right here. We want to categorize this price. We want to say the price is below $50. It's a cheap item. The price of that item is pretty cheap, but if it's higher than $50, it's an expensive item. We can display this and create this logic. I'm going to say if, and this is our keyword right here, we're saying if the price, and this is actually referencing this right here. We are actually referencing this variable. If the price, and we're going to say is greater than, or sorry, less than $50. Now, this right here, and let's scroll back up real quick, this is our operator. This is, I think, a logical operator. I'm forgetting the exact term, but this is an operator that's going to tell us whether it is greater than, whether it's equal to, whether it's less than or equal to. There's a lot of different ones that we can use. We're going to say if it is greater or less than $50, what do we want to do? When I hit enter after this colon, it automatically knew and indented this line of code. This is our block of code. Now, if this is true, this block of code is going to run. I'm going to say if the price is less than $50, I'm going to print out this is cheap. Let's go ahead and run this and see what happens. Notice we don't get an output. It's because this is false. It will only go to the block of code if it is true. What we're going to do is say if it is less than $100, just for this example, let's run this. It checked and said if this price is less than $100, print this block of code. It prints it out. This is a very simple one. We're going to get a little bit more complex in just a second because this less than $50 does not give us any output. We want to have multiple conditions that we can test. We're going to say if it's less than $50, then we will print this out. But if it's not, we can actually come right down here and we can write something else called an elif. This elif says if this statement is false, then come here and we'll have another if statement. Now, if the price is greater than $50, we'll do a colon. It will automatically indent for us. We'll say print. We'll say this is expensive. There we go. Now, it's going to first check this one. If it's false, if that condition is false, it will come down here and it will run the next one. I said less than. You guys didn't tell me that. I'm going to blame you guys on this one. Now, since I said price is greater than $50, which $75 is greater than $50, this is now true and it prints off this statement right here. Now, the last thing, and this is just nice to have, you don't always have to have this, is we're going to do an else. Now, what this else does is if this is false and this is false, whatever is under this block of code is going to execute. We'll say print and it will say does not fit into either. What I'm going to do is I'm going to make them both false really quickly. I'll say is greater than $100. First, it's going to check is it less than $50? No, it's not. It's $75. Then we'll check is it greater than $100? No, it's not and then we'll come down here and it will give us the output in the else. Let's run this. And let's see. What did I do wrong? Unintended literal string. That's because I have to close my string over here. Let's run this again. Now it gets does not fit into either. This is an if statement. I use these a lot and actually what I'm about to show you in just a little bit in these four loops, I'll combine these logics together a lot of times and I'm not going to get ahead of myself but in the four loops and the while loops, I'll often combine different operators and different logic to really customize it for exactly what I want. And so let's go down here. This one's going to be a little bit different. Now what we have here is very similar to this except we have a list here and this is a blank list. And what we're going to do is we're going to try to categorize this and then in the for loop in just a second we're going to do something very similar except a little bit more advanced with the for loop. Now what we're going to do is we want to say if this sale because let's say we own a store, if the sale is within a certain category, you know, let's say less than $100 or less than $50, that's a small sale. If it's say 51 to 150, that's a medium sale. And if it's over 150, that's a large sale. And so we can categorize this information and this will set us up for this next part. So we're going to create this flow of logic and wherever it lands in we're going to put it within that list. And so that will allow us to know what category or what a what list we put it in and what it's categorized as. So I'm going to come down here. I'm going to say if the sale and we're going to write this out all correct because we're going to literally copy it and put it down here as well. So we'll say if the sale is less than let's say $20, if the sale is less than $20, we're going to append this and we're actually going to place it in this small sale. So we're going to take this small sale, we're going to bring it down here, we're going to say dot append. And what is this going to do? This is going to append it wherever we place it or whatever number we place in here. So we want to take that sale and put it in here. So we're saying if this condition is true, if the sale is less than $20, we want to append this number or this sale, the $20, into this list. Now I'm going to write out the whole logic and then we will test it out. So now I'm going to say aleph. Now this is going to be a very similar logic. I'm going to copy this entire thing. Here we go. So now if the sale and now we're going to do if it's less than 100, if it's less than 100, this is going to be a medium sale. All we're doing differently is changing the condition and then we're going to append it or place it into this list right here. Now the very last one, I'm just going to say else. If it is else, doesn't matter if it's $101 or $10,000, it'll go in our large sale. So we're going to copy the large sale right here. Now we're only going to meet one of these criteria and the logic is really important here because if I put $100 here, we may have an incorrect logic and I'll show that in just a little bit. So it's going to say if this sale of $200 is less than $20, put it in the small. If it's less than $100, put in the medium. If it's anything else, which means $101 or above, put it in the large. So what we're going to do is we are going to also print these off. So I'm going to print off the small sale and then I'll print off medium sale. Let me just copy this just so we have it. We can see what it looks like and we can print off the large sale as well. And let's go ahead and run this. And so you can see that our logic worked exactly as it should. And I can even put large right here. Let's do a comma that should work. We'll do medium, comma, and we'll do small just so we can see a little bit better. There we go. So we have small, medium, and large. Now what it did was it said is it less than $20? That's false. That's our Boolean value of false. We won't run this code. Is it less than $100? No, so it doesn't go into our medium. Everything else is going to go into our large. Because $200 does not fit into that, it goes into the large. Really quickly, I want to test just one thing. If I put $100 or let's say anything, it could be $500 just to keep it in there. It's going to be true. But this is, let's actually, let me change one more thing. Let me do $300. So if this is $500, that's true. This statement is also true because we're also saying if the sale is less than $300. But let's run it and see what happens. It's only going to go into the small sale, even though it's not really small, but it's going to go into the small sale because this condition is true. Once this condition is triggered as true, it's not going to go to the next L of statement. So even though this is also a true statement, it's not going to actually get down there because of the flow of logic. So you have to make sure that you have the correct flow. Otherwise, you definitely can mess some things up. Now, what we're going to do, and I'm going to, give me one sec, I'm going to scroll down. What we're going to do now is I'm going to copy this entire thing. Okay, yeah, I already have all that. So I'm just going to copy this right here. What we're going to do is we're going to see how we can use a for loop. Now, a for loop is going to iterate through. It's an iterator. So it's going to iterate through whatever value you're giving it. Now, we're going to be passing through a lot of sales. Before, we just had one single sale, or one single sale. And so we had a logic for just that one variable. But what we're able to do with a for loop is we're going to do this exact same logic. But this time, we're going to be iterating through all the different values within this list. So we're going to start with one. And then it's going to loop through this logic. And then we'll go to the next value. It'll loop through the logic. And it's going to pass each of these values through our for loop. So let's see how this works. Now, I'm going to scroll down just a little more. So the for loop looks like this. We're going to say for, and we can write anything. We'll just say for the number. I could have said sale. But for the number, and actually I should say sale, shouldn't I? Because we're going to be using that in a little bit. There we go. So for the sale in, and that in says where are we looking? And what are we going to be looping through? So we're going to be looping through this sale amount right here, which is this big list. Now we do another colon. It says for sale and sale amount. Now we have our body of code. Now, when we have a body of code, we have to indent it. And I think I should be able to do this right here. So all I did was I copied over everything. I hit tab. That's our indentation that says for each of these values, and this is just a placeholder. So the one becomes the sale. It's like saying sale is equal to one. And then the next time it passes through, once it runs through this logic, then it's going to say sale is equal to 20.70, our next value. And it keeps looping through. We don't have to do it manually though. That's what's so great about the for loop. So it's going to loop through this, and it's going to append all of these values into our different lists. So let's go ahead and test it. Let's see what happens. Let's run this. And so as we can see, for the small amount, which is less than 20, there's only one value. And it got printed out right here. There's only one value that's in the small category. Then we have our medium, and that should be less than 100. And that's exactly right. And then we have a large, and so we have 100 all the way up to 700. Now, you may notice we have this 100 here, and that's because in this Elif statement, we said sale is less than 100, which means it is exclusive. It does not include the value that's right here. If we said, excuse me, is less than or equal to, let's run this again. Now that 100 gets included in the medium. So now we're including or being inclusive of this value. I'm going to put it back to how it was. There we go. So that is a for loop. And again, I often use these for loops with some type of logic within it. I'm kind of working through these values in this list for loops. These iterators are super important in Python. They're used a lot. Now, the next one that we're going to look at is a while loop. Now, let's go back up here real quick. Because the while loop is this right here where we're saying if it's true, run the block of code. If it's false, just move on, essentially. So let's come down here. And let's say we have these temperatures, and give me one second. I'm going to check on the time. All right. It's 11.30. I got to keep going. Let's keep it moving. So these while loops are really great for trying to reach a certain point when something occurs, break out of that loop, essentially. So what we're going to say is we're going to say while the temperatures actually just wait, give me a second. I need one more. I need one more. Let me zoom out. I'm going to put this down here. I'm actually going to get to this in just a second. I'm going to do a simpler version, and then I'm going to get to this one, because that's a tiny bit more complex with indexes and stuff. So I'm actually going to just put it down here in the first place. So let's say we're going to do while. Now, what we can do, and this is extremely common in Python, is we use something called a counter. And what it does is while it's looping through, you can add to that counter. And there's a ton of different use cases for this. But I'm just going to show you how it kind of works. We'll call this counter zero. We're going to say while the counter is less than 10, what do we want to do? We're just going to print out that number. And follow along with me for just a second. Within this while loop, what we're going to do is we're going to add one to this number. So I'm going to say counter is plus or equals or equal or plus. Let me try this one to one. Now, what we're essentially doing here is this counter is outside of our while loop. Once it enters our while loop, this is going to continue running. This won't be affected in the slightest. This is just a store in memory while it's looping through. So we're taking this counter, and that's going to be a zero right here. So while that zero is less than 10, when this is true, we're going to run this entire block of code. So we're going to print out that zero. Then we're going to take the zero and add one to it. This one is going to loop back up into here, which blew my mind when I first learned about these and when I first started using them, it did not click. So I hope this is making sense. Let's print this out, let's run this, and let's see what happens. So I'm going to run this. And we get zero, one, two, three, four, five, six, seven, eight, nine. Now, when it gets to 10, because eventually it does, it gets to nine here, it says nine is less than 10, which is true. It comes to print. It prints out the nine, and then we add one to it, and this becomes a 10. So when this becomes a 10, then it becomes a false statement. So it says 10 is less than 10, which is not true, and so it defaults to false, so we break out of our while loop. So in essence, we're just printing through counting by ones. Now, we could do anything. We could do a two, and it'll go by two, four, six, eight. We could do three. And you get the idea. This number, this zero gets added, it loops back in, and as long as this condition is true, it's going to continue running this block of code. And just one small thing, this is where a lot of people will make the mistake of creating something called an infinite loop. And I'm not going to do it, because it will completely ruin this demonstration, but you go ahead and try it. It will happen. If I don't have this counter, and I'm not going to run this, I'm not even going to try to run it, because then I'll have to reset everything. It'll take like five minutes. This counter is equal to zero. So if I say while zero is less than 10, print counter, it's never going to add anything. This is always going to be a true statement, because it's going to print the counter, it'll still be zero, and then it's going to say zero less than 10, true. So it's going to print these out indefinitely forever. Eventually, your system will crash, or your server will crash, and you won't be able to write your code anymore. So just a mistake I've made many times. Don't do that. Now, let's go down to this temperatures right here. And what I, just as an example, what I might use this for is I'm tracking real temperatures live, and I've done something like this actually with, I used to do this with cryptocurrency, or watch prices, or whatever. I would have an automatic system running. I would say while the price is, yeah, while the price is greater than this, I would say don't do anything. Or wait, let me get, let me think of that. Oh, I'll say while the price is lower than a certain price, then send me an email. And I used to do this for a bunch of different things, and it was just so I could purchase things faster, because I didn't, there are some services out there that do that now, but I didn't know of them. And what I used to write is something like this, because the data would come in and be flowing in and it would give me live prices. And once it reached a certain number, I would then trigger the code to send me something. And so what we're going to do is we're going to say while this is really low, while the temperature is let's say less than 90, that's a cold temperature and that's great. When it reaches above that, we want it to break out of that code. And so we'll say while temperatures is less than 90, we're just going to print out the temperatures. We're just going to keep it simple. But we're going to encounter a small issue really quick. And you'll see in just a second. So I'll say temperatures will be the same thing is equal to actually, let me run this real quick. So here's the issue that we're getting. Right now, this is being stored as a tuple. And we could store it as anything. We could store it as a list, as a tuple, or other things as well. But right now, it's a tuple and it's stored as a temperature. So what we're trying to say is this entire tuple is less than 90, which is not accurate. What we need to do is we need to be able to pull out one value at a time. Now, we haven't really talked about this yet, but this is something called an index. This tuple stores these values and underneath the hood, it's saying, and let me come down here, this is position zero or index zero. This is index one, two, three, and ignore how that's not centering on everything. But these values are stored at a specific position. So what we're going to do is we're going to say start at position zero, the very first one. And then we want to print position zero. Now, I am not going to print this. This would be an infinite loop. I've learned my lessons. But what we're going to do is we're then going to add to this indexed position. Here's how we're going to do this. We're going to say x is equal to zero. And then put this as x. It's the exact same thing. But now we have our counter. Encounters are pretty important in while loops. So now we can say x plus or equal to one, which adds one value. So then the first time we check it, this is zero, which is our 70. Then it goes through and we add one to it, which then we look at the first position, which is 72. And so let's go ahead and run this. Let's see what we get as our output. And this is bad. I just need to comment this out. There we go. So let's go ahead and run this. And let's see what our output is. So we get 70, 72, 75, all the way up to 88. Then it got to 91. And notice 91 is not printed. That's because when 91 got here, and that's five, six, position seven, when it gets to position seven, this gets put right in here. And that position seven is the value 91. So 91 gets placed in here. It says 91 is less than 90. That's false. So because that's false, we no longer run this code and we break out of it, which is, for some use cases, perfect. But maybe not for this one. If we want to still notice that these are 87, 81, 76, these are below 90. So it's going to trigger it and say, whoa, it's above 90. Do not run any more code. And so this is kind of something similar to what I've used for walk prices back in the day. I used to use something, some logic like this to say when it's below a certain value, then let me know or print this off. So that is, let's scroll back up. We just went through a lot. Those are statements operators. They help with control of logic. Now, the next thing that we're going to look at, and let's go back down, are functions. And let me check the time. Oh, boy. Oh, boy. We're not going to get through everything. Here's what I'm going to say. I have all the code for this. I'll pass this along to a career foundry. I'll put this in the bottom of my description once I save it to GitHub and do that. I want you guys to be able to have all this code and all this stuff because we go into a lot of other things, which I didn't know this was going to take this long, if I'm being honest. Just so you guys can have this code, I'll put it in the description and hopefully they'll send it out as an email as well. So let's start going into functions. And then after functions, it gets into what I would consider more of the advanced things when we start using different libraries and whatnot. Now, a function is one of the more important things if you're really diving into Python to kind of understand. Because when we work with the more advanced things like libraries and packages, 99% of that stuff is stored as functions. And what we've done is we've actually used a few functions before. One's like print. Print is a built-in function within Python, but we can create our own. And so what we're going to do is we're going to create our own function and we're going to see how we can do that. Now, we have multiple different parts of a function. We have to first define or say D F to say here's I'm about to create a function. Here's what it's called. We name our function and functions take in values. And you don't, I guess, always have to take in values, but I would say most do. And I'll show you that in a little bit. Now, what this does is you're creating this function to store code. And so you can write thousand lines of code and you can store it in a single function. And then you can call that function later and it calls all of that thousand lines of code without having to actually run it and in, you know, having a thousand lines of code in the cell. All I have to have, all I have to call is this function name. So let's go ahead and see how we can do this. Now, the first thing I'm going to create is a super simple function. I'm just going to say define my first function. And I'll keep it empty for the parameter. So I'm going to get to parameters in just a second. But all I'm going to do is I'm going to print out, I like Python. Now, this code is going to be stored within this function. So if I come, I'm actually going to save this. I'm going to run it. And so now in memory, we have this function, first function. If I come down to another cell, I'm actually going to copy this. I can call, and this is us calling this code. We're calling that stored code. I'm just going to call first function and I run it. It's going to call this. It's going to execute our code, which all it says is print I like Python. So super simple. But it gets a little bit trickier when we start adding things like arguments, which can also be called parameters. And then we have a few different ones that we're going to take a look at. And hopefully I can get through all of them. So let's go to the first one. Now, let's say, let me check my notes real quick. Let's say I want to create one where I pass through a name. So we have a game. You have the data stored in the back end. And you need a call to say, hey, congratulations to this person. You won. And you want to say their username or their gamer tag or whatever it is. So I'm going to say call name or congratulations. You can call whatever you want. But now I want to pass through at some point this variable or sorry, this parameter. This parameter is something that we call just so you can look ahead. We're going to call this and let's say Alex. I'm going to pass through Alex as this parameter. And this parameter then gets passed into the code. So when I do a colon, I hit enter, we're going to say print. And I'm going to say name. And then we'll do a comma or you could do a plus sign or you can do whatever you want. You can say name, congratulations. You won. Now, when we save this and we run this, this Alex is going to get passed into right here. And then we're going to say, congratulations, you won. So let's go ahead and create this function. And now we're going to call it. And we'll call it by passing through our parameter. We have to. So let's go ahead and run this. We get Alex, congratulations, you won. And in fact, I was right. This comma automatically separates it with a space. So I'm going to recreate that. I'm going to run it. And now it says Alex, congratulations, you won. Now imagine we created some logic to pull from a database. And this is something that, similar to something I've worked on before, which is you need to call data and have it pass through this function and make it dynamic. Dynamic means it's not a hard coded thing. I'm not saying this is Alex because then if Sam comes along and plays the game and wins, then that doesn't work. And so this makes it a lot more dynamic. So I'll come back up here. This is very simply, probably one of the more simple functions or arguments that you can pass through. Now, just so you know, if you have something that requires an argument or a parameter, whatever you'd like to call it, they're pretty interchangeable, you can, if you run it without it, not passing through that argument, it's going to say you're missing a required positional argument name. So we do have to have that in there in order to run. Now I think I'm only going to be able to get into the functions because I still have quite a bit within the functions to get through. So again, all of the stuff below, I'll have it in code. I'll send the codes that you guys are going to have this. The next one that we're going to look at are arbitrary and keyword arguments. Now arbitrary functions or arbitrary arguments, I guess you should say, were really, really, really confusing to me. I had a tough time understanding how they worked. And I'm going to give this example. Let's say we have an arbitrary tuple. I'll just pass through any value. We'll just do one, two, three, four, five, six, seven, eight. And I need to assign it by saying equal. So I have this tuple here. And what I'm going to do is I'm going to create something that pulls in that tuple. Now I made it a tuple specifically because arbitrary arguments only pull in or only read tuples. You can pass through lists, but you have to make it a tuple before it's not going to get into that too much. But what we're going to do is we're going to add some of these numbers together dynamically. And so we're going to say define, we'll say adding numbers. And I'm going to pass through two, whatever variables we want. So I'm going to say star. And then I'm going to say arguments. And you can say anything. You can say args, arguments, arbitrary. You could say, I don't know, fluffy. You can pass through anything you want. I'm just going to keep it that because I think it's funny. Now what we're going to do is we're going to add two numbers together. And I'm going to say print. And I'm going to get to print in a little bit because there's, I'll get down a little bit. Print versus return. We'll check that out in just a second. Now what we can do is when we pass this through, it's going to get passed into here. And then we can take it using or we can take specific values from this tuple using the index. So let's say I want to add position one, which will be this two. And then I'll do plus, and I'll say fluffy, whoops, fluffy position two, which should be the three. And it's going to print that out. Got that wrapped. Now I'm going to take this adding numbers. And I'm going to run this. Nothing is going to happen in what you can see. But on the back end, we saved this in memory. And then we created this function and saved it in memory. So this tuples now saved as arbitrary tuple. So what we're going to do is we're going to come down here and we're going to pass through this tuple. And we're just going to put a star here. And the star is going to signify, hey, we're passing it through as arbitrary. Now let's run this and we get five. And so we're getting this position one and position two in our index, but we're not saying it specifically in here. We're not passing through a single value like two or three. We're passing through multiple arguments. So that is position, or sorry, that is arbitrary arguments. Now the next ones that I want to look at, and then we'll do print versus return. And then we're not going to get to this other stuff today. That may be, you guys are going to have to ask career foundry, but that may be a whole, maybe just advanced, an advanced lesson, because there's so much in Python. It's immense. So let's go to this next one. Now we have positional arguments and we have keyword arguments. Now we've already looked at positional. In fact, I'm going to, no, I'm not going to do that. We've already looked at positional. I'll explain that in a second. But then we have keyword as well. So let's define another argument. And let's do, we'll call this one squared. I cannot say that. Now with squared, we want to take two numbers. We want to take the number, so we'll do num. And we also want to take the power, because if you do squared, and actually I'll just do to the power of, because otherwise it won't make sense. So here we have num and power. Now before we were just doing, so let me write this out real quick, we'll do number to the power of whatever we call it. Now this right here is kind of like saying two to the power of five. This is essentially what this is doing. And we can just print that out. There we go. All right. So let's look at this one really quick. So I'm going to define this. I'm going to run this. Now what we're going to be taking a look at is positional. And before we did this with this one, except there's only one value, so it can't really make that mistake. But this position is position zero, and it gets passed into the first position. So what we need to do when we call this, and let's do it just like this, is we're going to do two. And that's going to be position one, which is number. And then we have power. So we're going to do two to the power of four. Let's go ahead and run this. And we get 16, which is the right number. Now if I switch this around, I do four comma two. Now we're doing four comma two. So four to the power of two, which is 16 as well. So this is four times four. Now what if we didn't want to do exactly that? What if we want to do a little bit backward? I can say power, and this is our keyword. Power is equal to two. Num is equal to four. This is no longer positional, because this power is actually in this position, and we're calling it in the first position, versus the num, which is in the first position, we're calling it in the second position. So if we run this, we're still going to get 16. It's going to work properly. One tiny little note, and this is going to be the last thing I mentioned before, the print and return, which will be the last thing we look at. This, you can have positional and you can have keyword arguments at the same time. But what if I do just like this? Just the two. This two is going to be assigned to this num, and then we have num assigned to num. So we have keyword and we have positional, and nothing gets assigned to power. So let's go ahead and run this. It's going to say power of got multiple values for the argument num. That's not a good thing. We need to change that. We can still have it as positional and positional and keyword. We just have to do it in the right way. So you can have this position, and then for this one, you can say power. Because now two is still positional and assigned to num, power is still going to be assigned to power, and it will work. Now this is next part. Let me drink a sip real quick. This next part I'm going to show you is something that confused me to no end. It took me a long time to learn. I'm going to try to explain it really simply because as you get more advanced with Python and creating functions, this is very important. And this is print versus return. Up till now, I've just been printing stuff off. But that really limits what a function can actually do. Because when you print something off, you're just printing it onto the screen. You're not storing that value anywhere. So when we do this, this 16 is just being printed to the screen. It is not stored anywhere. And so return actually stores that value, which you can use later. That's extremely important to understand because print is just printing it on the screen. That's all it's doing. So I'm going to give you a little example and work through this with me. Let's say define a return sample. This is our function where we're going to demonstrate return. And I'm not going to do anything. We're just going to keep it super simple. I'm going to say return 100. So return 100. That's all I'm doing. When we do return, we do it just like this, return sample. If I run this, it created this function. And then we called it and all it did was return 100. That's all we did. Now actually, I'm going to do this on another one. Now I'm going to copy this exact thing, exact function, except I'm going to say print. And then we'll say print right here. And that's the only difference. We're printing versus return. Now let's print this out. And this looks exactly the same. And it's the exact same output. But here's the difference. What if I wanted to take this print sample? And I wanted to use it further along in a different calculation. I had a lot of code in here and right in here. And I want to use that. I want to add whatever this value is in the print sample. And we'll do plus. And let's do 100. Now you might think, okay, we have 100 here. That's our print sample. We'll do plus 100. That should be 200. Let's run this. We're going to get this error. It's going to say unsupported operand types. That means it doesn't support you adding this data type and this data type, which is a none type and an integer. That's because nothing is being stored on the back end. So there's nothing there. There is no data type there. Now what's going to happen if we use return sample? Remember return sample is actually going to store it. So when we call this, this return sample is actually going to be 100. Unlike the print sample, which stores nothing, it just prints out the code. This return sample will do 100 plus 100. And we will get 200 as the output. Now, depending on the use case, what you need to do sometimes, all you need to do is print something to the screen. A warning, an error message. But if you're doing calculations with it, which I often do with Python, you want to be able to run the code, store the value, and use it later on in different calculations. That's what return does. So it stores that value. So really, really, really important to note, not just with calculations, but you can store names or lists or tuples. You can store values in that function. So that is what we got through. I would say this is like, we got to the intermediate. A little bit of the intermediate with these functions. I really wish I had like another hour. I didn't know that they would take that long. But I have all this code on my screen over here. So don't worry about that. I'm going to save that, send it over to Will, and so that he can get that to you guys. But this is the more advanced stuff, where we're taking actual data sets, and we're working with them. So let me stop sharing. Stop screen sharing. Oh, boy. Now it's just me. That is it. So that was our Python hands-on tutorial. That was our live coding. I guess can be a little bit verbose. I can talk a lot. But again, I tried to condense it down as much as I could. I just, it's just a lot. So I hope that that was really helpful. I know we're going to have some Q&A time when Will comes back. But thank you guys. I really, really appreciate you guys letting me talk for an hour straight. I love this stuff. This stuff. I thought it was super fun. I hope it was fun for you too. Alex, thanks so much for presenting tonight. Great feedback. Great engagement from the audience too. And some really great questions. I think we've got a mixed audience tonight. There's definitely some people with more experience and some people with less experience. That's completely normal. So we're going to take a mixture of questions from both sides. And I'm also going to take some questions over from YouTube and LinkedIn too. So do drop your questions there. I'm going to kick it off maybe with a question not directly related to Python. But I think I'm going to start off with some beginner questions also. On YouTube, Sir Hill is asking, is it possible to get a data analyst job without experience? Oh, yeah, it is. And I used to mentor people. So I mentor it a lot. I think it was like 205 if I had tracked. It was over the course of two years. I had a mentorship program. I don't do it anymore. I'm sorry guys. But I actually worked with a lot of people who had zero experience. And this is just like a year ago, right? A year, two years ago. So this isn't like five years ago when the market was easier. But a year, two years ago, people who were teachers, nurses, warehouse workers, all sorts of different career paths who were like, I don't like what I do or I don't make enough money or whatever. And they were able to make that transition. It's absolutely possible. In fact, I had no experience in data analytics when I got in. I'm also an example. I just worked in healthcare, like six months out of college. And then I accidentally stumbled upon data and fell in love with it. So yes, absolutely possible. Awesome. Thanks so much. And for everybody watching, I will be sending by email. For those watching on Big Market, I will be sending a recording round and also the files so you that you can work along. Susan had a question early on which application we're using to demonstrate, Alex. So that's called Jupyter Notebook. And it's a notebook, but there's also something called an IDE. So look into those terms. In my actual coding from usually my more complex stuff, I'm using something called Visual Studio Code. But what I was using for demonstration purposes was called Jupyter Notebook. Still really great. I've used it in my actual job. There's just some functionalities that aren't in there with a full-blown IDE that you can get. And so I like Studio Visual Code myself. But that is Jupyter Notebooks. You can install that using Anaconda. If you search Anaconda Python or Anaconda download, you can get that and download that and use it. Awesome. Fantastic. And as I said, I know that we move quite fast this evening and people are asking about next steps also for beginners. Just a quick shameless plug here. I would recommend checking out the Career Foundry Data Analytics Short Course. It's completely free, spread over five days. I've dropped it on Big Market. Do check that out if you're completely new to data analytics. And maybe this was a little bit deep. Do go and check that out. Alex, obviously you get a lot of people also applying for data analytics jobs and lots of beginners when they're just taking that first step into the industry. What kind of skills or what kind of tools do you want to see on a junior data analyst's, you know, I'm speaking German now, curriculum? Yeah. I've hired quite a few people. I remember when I was getting hired as a data analyst, genuinely the biggest things. And you have to remember, every company is different, right? So you can't just have these skills and you'll be able to apply to every single job. There are going to be certain skills that certain companies are looking for. Some are going to really value SQL. So if you have SQL on your resume, that's really good to have. That's probably one of the best skills to have on your resume. But then sometimes they're going to have other random skills that you've never heard of or random tools that you've never heard of. A lot of times I recommend people learning things like SQL, Excel, Tableau, just as a very beginner because those concepts of working with that structured data is really applicable to a lot of these different platforms and tools and skills that other companies use. And so those are the starting things that I would learn. I think now, even today, a skill or a tool that you should start looking at and using are things like cloud platforms. In the future, I'm going to go through a whole series on my channel of cloud platforms because I think that is becoming much more of a necessity because so many companies are switching to the cloud. So if you can start learning things like Azure and AWS and just learning the basics of how the data works in the cloud, that is also a big leg up to other people who haven't learned that yet. Wilson, thanks so much. I'm going to take a couple of more technical questions. Robert is asking, hey, Alex, do you ever actually use the finally clause in Python after if, else, ifs, and else? I can't remember a time where I've used it honestly. But yeah, and he's referencing for everyone else who's asking or whoever's watching, in those iterators and that logic stuff that we were looking at, there's things like break, continue, pass, and finally, and you can use those to help control the logic. I didn't get it going to all that because, again, I had a smaller time, but you can use those to help control the flow of logic. I don't think I do use finally that much. I know I have in the past, but probably not anytime recently. Awesome. And one of the main things that we're getting through a lot of career functions at the moment is the impact of AI also on the data analytics industry. How do you see AI interacting with Python? Yeah, I mean, I literally was writing a program a few days ago and I was using AI with it. Here's the thing that I've, and I've been using it ever since they started coming out, really becoming popular late last year. I have been using it pretty consistently. And now it's kind of part of my workflow. It is really great, but I already, there are a lot of limitations that I found. I use GitHub Copilot. I just use straight up chat GPT. I've used Bard. I've used a lot of different flavors and things. It is really good to use, but even the program that I was writing just a few days ago, I needed a certain level of complexity to it and it just, it couldn't get me there. So it got me like, help me get like 80% of the way there, but then that final 20%, like I could not get it to do it. I really wanted it to, so I didn't have to write it all out manually. But I had then eventually just had to write it out myself. What I will say is, and this is my, I firmly believe this, I really think you need to learn the basic concepts of, let's just say Python for now, but any programming language. I really think you need to understand the basic concepts of how it works before you start having AI help you write it. Because when you reach a certain level, more work, though a lot of this stuff that you'll do are small, little programs, small things. And it's, it's pretty simple in your personal projects and whatnot. When you get into the real world, when you start working with these tools in a job, that becomes like a one out of 10 on the complexity scale. And when you start getting up to the five, six, seven in complexity, AI, if you don't understand how things really work, it causes a lot of issues. For example, just performance issues. I was using it for SQL like a month ago and I was trying to get AI to help me write this query and it was giving me an output that was working, but it was the most, it was extremely unoptimized. So it was taking a lot longer to run, which cost me more money because I'm paying for this cloud platform to start my data. And so because I knew that, I could then optimize the query and say, Hey AI, no, don't write it like that, write it like this. And then it did it kind of close. And then I got it the last like 10% or so. And so if I hadn't have done that, and you know, that's just in a purse for my personal data that I store for like my business and my company, if I hadn't done that, it would have cost me a lot more money in the long run. And then you take it into like an actual business. I used to work at a fortune 10 company as a data analyst where I'm working with hundreds of millions of rows. These little optimizations, these little things can have a big impact. So I'm really long winded on that question, but AI is fantastic. It's a great tool. Highly recommend using it, but definitely understand how things work before you start implementing things, especially if you're doing it at work, because it genuinely can cause a lot of issues. If you don't really know what you're doing. Great answer. I think a couple of months ago, also Alex and I did another event looking at how to use chat GPT. I think if you go over to Alex's channel, Alex, the analyst on YouTube, and you go to the live events that we've done together, you'll find that there. So if anyone interested in AI, that's a great webinar to look at. There's a great question that's come through on Big Marker from Nimra and apologize if I pronounced anyone's name wrong. And the question is, I have good knowledge of Python SQL, but I never feel ready for applying for jobs. I feel like I always lack something and I should learn another skill or learn a new tool. Is my approach right, or do you think I should start applying? Start applying. I'm very, very, very confident that you're never going to feel ready. Even when I was like a data analyst, I never felt fully ready. And I was applying to other jobs. I had already had a year experience. I still didn't feel fully ready. I was like, I felt like an imposter. Like I didn't know what I was talking about. But there are positions out there that are very willing to help you grow those skills and help you learn. And so if you don't apply, you're not going to get a job. You're just not. And so if you have the foundational skills of you know, SQL Excel, Python, a little bit Tableau, if you have those foundational skills, the best way to learn is by applying, getting interviews, asking, you know, they're going to ask you about, do you know this and the skill? And if you just bomb that interview, you at least know that's something that you need to learn so you can go and learn it. And it's a growing process. So it's not like if you apply and you don't get a job right away that you failed, you just need to grow in some areas and just take it with a grain of salt. Not everybody knows everything. Like even me, I don't know everything in Python, although I've gotten very good at Python. There are still things that I see every day where I'm like, Oh, I didn't know you could do that. And I'm like, that's really interesting. But I know the foundational stuff. And so, you know, that's, I think that's the most important thing. You know, if you know the foundational stuff, I think you should put yourself out there and just see what happens. Awesome. And related to that question, Alex, how do you keep updated with everything that's happening in the industry? Because it's moving quite fast. So how do you update and know, you know, what's the latest and greatest? I think I'm in a different, a unique position where people send me stuff every day. And so, I get, I get tagged in things and I get sent things every single day via email and Instagram and LinkedIn and Twitter. And so it's just, I get bombarded with stuff. And so I filter through things. A lot of the stuff that they send me, though, is, you know, unique things. I genuinely, I find Twitter to be or X, sorry, I find Twitter slash X to be one of the better places to kind of stay up to date with a lot of the tech stuff. But there's also a lot of like crazy hype on Twitter. So like, you know, just take out a lot of things that you see with a grain of salt, but a lot of these, a lot of new advancements and new technologies and new things. I see demonstrations or things on Twitter or X or whatever. I can't not, I can't not say Twitter. But you'll see it on there. And you can kind of keep up. That's where I would say I probably get like 50% of it. And then other things are like articles on LinkedIn and articles that people send me. Career Foundry team members ask you, have you ever, what's the strangest thing you've received from a fan? I don't really receive strange things. In fact, not strange, but this is the coolest. This is back when I was like, I had 100,000 subscribers. I have a P.O. box that people can send things to me. And he sent me, I was asking for things from my background because I didn't have anything. And he sent me this as this wood dice. And I love it. It's my favorite thing. Yeah, that's it. I am mindful of the time. I will take another couple of questions. I think there are some great questions coming through. And so much of being answered by the audience too. Jasky Rat is asking, I think it's a good question for beginners as well, because everyone's working on projects and portfolios. Where can I find data for projects in my portfolio? That's a good question. There's two main places that I look. There's, okay, there's three main places that I look. There's sample data. There's real data that's already pre-organized for you. And then there's in the wild data. Now, for sample data, I like Kaggle, thousands and thousands of just free data sets, kaggle.com, highly recommended. Some of it's real, most of it's just curated, filtered down, simple data. Then you can get real data. I use something called Google data set search. It's not just Googling data sets. There's a thing within Google called Google data set search. I search for data sets and they're real data sets. I search for healthcare data, financial data, stock data. These are all real data sets that they'll help you find. And they bring you to other websites where you can download the data. I use that a lot. Then there's in the wild data. And this is where we would have gotten at the very end, which is web scraping, which is where you go and you find data on a platform or a website and you write code to extract that data. And that's in the wild there. That's just data that's out there and you are taking it and using it for your purposes instead of downloading it from somebody who's already curated for you. That is something I've done in my job many times and it really pushes you into the data cleaning, creating data pipelines, creating data cleaning processes and storing that data efficiently. It pushes you really hard into those areas because once you start downloading or once you start scraping a certain amount of data, you can't store it in Excel anymore. Then you have to figure out a process to then store it in something like a SQL database, which is really fun. For beginners though, sample data, Kaggle, if you want to get a little bit more challenging real data, use Google data set search. Awesome, great advice. In this webinar tonight, we've really dived into the hard skills in data analytics, Python, we've really gone into the nitty-gritty. Cheryl has asked a great question about soft skills and maybe you could just elaborate a little bit about what soft skills are valued in the industry of data analytics. That's a really good question. There are different facets. I think just as a generalization, I feel like I did really well in my career and a lot of other people that I know who did really well in their career in data analytics had this kind of, I wouldn't always say I had a super outgoing personality, but I think an upbeat positive personality goes a long way and that's kind of that thing that you, it's not necessarily a soft skill, it's just a personality thing. If you can make friends, you can make connections with people, that goes a long way. It really does. Another one, and this is kind of more of a giant actual soft skill is what I would say, is being able to, problem solving is a very generic term, but when you're working these problems and you're able to say, okay, I have my skill and this person over here has this skill and you're smart enough to know that I can't do this myself and you incorporate them and you collaborate with people to solve issues, that is like a really big soft skill that learning how to work with others efficiently and knowing your skill sets and their skill sets and combining them together to get worked on faster. That is like one of those really intangible skills that I think is really impressive and I've seen it within, when I was an analytics manager, I've saw it within my team and I think that was amazing and I think I did that well as when I was getting into it as well. I think really, not just me, but others who really pushed that collaboration aspect well and I think that's one of those intangibles that's just really impressive when you see it. Awesome, thank you so much. Alex, I'm mine from the time. We did get a lot of fantastic questions this evening. I thought this was an incredibly informative webinar. It was a deep dive. I think we were ambitious, but I think you gave some great explanations and I think we definitely added some value, especially for the audience. Thank you for everybody watching. It was really great to see all the engagement. As I said, I will be sending around an email tomorrow with the recording and I'll also include some other links and also some of the files that we were using this evening. A couple of things. I did drop it in the post earlier, but we are going to be hosting an event with Dr. Humero, who is a career foundry mentor, but also a director of engineering, an introduction to data analytics. Do check out that if you want a little bit more of an early stage introduction to data analytics. Also, for anybody watching from career foundry, do check out Alex's YouTube channel, Alex the analyst, so much great content there. As I said, we've also done some collabs in the past where we've explored some different topics, different questions, and Alex will be joining the career foundry channel again in November and December. The events aren't yet on the career foundry events page, but will be soon. We're also going to be looking at data trends for 2024, so do check that out. As I mentioned at the very start, we are currently offering career change scholarships worth up to $1,425 or 1,245 of the data analytics program here at career foundry. If you've got any questions about that, do book a call with one of our program advisors on Big Market. Just click the sticky note and if you're watching over on YouTube, do click the link in the description below. I think that's about it from me. I'm going to sign off now, Alex. Thank you so much for joining. Thank you so much for bringing your audience. It's always a pleasure to host you on the channel and I look forward to seeing you in November and December. Thank you for having me. I appreciate it. Big Market always also moves around the end webinar thing. I'll just find the end webinar here. Thank you so much, Alex.