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