Python 101: Learn the 5 Must-Know Concepts

Tech With Tim · Beginner ·💻 AI-Assisted Coding ·3y ago

Key Takeaways

The video covers the basics of Python programming, including immutable and mutable types, list comprehensions, function arguments, and threading, using tools like NordPass.

Full Transcript

[Music] if you're interested in becoming a developer that writes any type of code in Python then you need to understand these five very important python Concepts these are what I see most beginner and intermediate python programmers making a ton of mistakes with and misunderstanding when they're reading through production code the goal of this video is to make sure that when you're reading through production python code you understand what's happening you know the concept and then you can reproduce that code and write your own pull requests and own features using python code that other developers will understand and expect so with that said let's get into the video after I share with you the first very important concept you need to understand which is the sponsor of this video nordpass nordpass is the ultimate password and credential management solution that I've actually been looking for for a long time now I don't know about you guys but I have a lot of passwords credit cards Bank details private Keys Etc and oftentimes I need to share these with my co-workers making it a constant struggle to not only keep this data secure and safe but to allow them to access it quickly without having to message me all the time now nordpass fixes this problem because it allows me to store both my personal or my business data in a single secure location and then give different access to members of my team now if you don't believe me you can check it out from the link in the description and use the code Tech with Tim which means you'll no longer have to be sending messages or receiving messages asking for passwords not to mention the nordpass has features like autofill data breach detection and activity log a password generator and much more check out Nord from the link in the description and use the code tequitim for a three month free trial so you can take control over your data and your accounts thanks again to nordpass for sponsoring this video so the first concept to go over here is mutable versus immutable types now this is the concept that most beginner and intermediate programmers make mistakes with don't worry if you already understand it there's a lot more complicated Concepts so stick around for the rest of the video regardless an immutable type is something that cannot change a mutable type is something that can change an example of these in Python is the following so immutable types are going to be our string our ins our floats our Boolean our bytes type and our topple type all of these are immutable meaning once you define this you cannot change it however we have mutable types in Python which are the list the set and the dictionary and pretty much any other type used from some third-party library or module these can change which means once you find them you can actually modify them let me give you a super quick example here of immutable versus mutable then we'll go into a more complex one using a function which is where I see most beginners make a mistake okay so let's say we have some number like x equals one and we say Y is equal to X and in fact let's change this to a tuple which remember is e mutable meaning we cannot change it actually to quickly show this to you let's try to do something like x0 is equal to one where we're trying to change this Tuple without reassigning something to this variable so if I go here and run my code notice I get an error and it says the Tuple object does not support item assignment now the reason it doesn't support that is because this is immutable that means that once I Define this Tuple I cannot change it now if we go here and do something like Y equals X and let's come and say X is equal to one two three I just want to show you if I print out both X and Y here that my change to X here after assigning X to Y did not affect y the reason for that is whenever you're using immutable types when you do an assignment to another variable so I do something like Y equals X it makes a copy so an actual real copy of this immutable object meaning that if I now go something like X is equal to one two three that's not going to affect y because I'm not modifying what Y is storing I'm just reassigning a new value to X I know that seems trivial but the reason I'm illustrating this to you is because this works differently when we change this to a list so if I change this to a list now and then I come and do something like x 0 is equal to 100 you might think that Y is not going to change but when I run this you see that both X and Y have the same value now the reason for that is when you're using mutable types and you do something like Y equals X here so you're signing a variable to another variable and this variable is storing a mutable type what happens is you actually store a reference or an alias to this same object meaning that if I make a change to the object like I'm doing right here it changes for both of these variables because they're actually storing the same object in fact they're storing a reference to the same object so again if you change the underlying object then it changes for both X and Y that's the difference between immutable and mutable types now let me just paste in a quick example here that will illustrate this even a little bit further so you can see in this example we have a function that Returns the largest numbers it Returns the N largest numbers actually what it does is it sorts the list of numbers that it accepts so what I've done down here is I've created a list of numbers I printed out what the value of the list was before I called the function and then I printed out with the value was afterwards now take a guess if you want it what you think the output is going to be but I'll go ahead and run the code and you can see here that we actually get the list before that's unsorted and then the list becomes sorted afterwards now the reason this occurs is because what happens is when we call this function we pass this nums list as the parameter numbers now since we're passing a mutable object a list is mutable when we do a numbers.sort what this does is actually sort the list in place now numbers here is going to be storing a reference to this same list so when I sort the numbers parameter here since I had passed in my numbers array it ends up sorting that numbers array that's down here seems a little bit strange but the reason this is occurring is again because we're using a mutable object so the point here is that you need to understand when you're using mutable versus immutable objects because you could have functions like this that can perform side effects on your mutable objects this is referred to as a side effect because what happens is one of the parameters is being mutated or modified inside of the function sometimes you want that to be the case sometimes you don't want that to be the case you need to be intentional when you're writing your code so the next concept to understand here is list comprehensions now the reason you need to understand this is because it's used quite a bit in Python and oftentimes you'll see people writing fairly complicated comprehensions to simplify a line of code now this can kind of do the reverse sometimes it can actually make it more complicated regardless you need to understand what they are so that you can actually understand them if you see them in some production code so let's have a look at a list comprehension so the most basic comprehension you can do here is something like X or we'll go with i for I in range and then maybe something like 10 and in case you can't guess it here what this is going to do is give me an array that contains the numbers 0 through 9. so let me open up my terminal and run this and there you go we get zero through nine so this is a list comprehension where essentially you write a for Loop inside of a list what you do on the left hand side is you put but the value that you want to populate the list with and then you have some kind of iterator in this case we have a for Loop that's going to Loop through and generate these different values now this is a very simple list comprehension you can make much more complicated ones for example we can have a list here instead so now if I do a list we have a bunch of empty lists inside of this list but just like we have a list comprehension here we can have one inside of this list so I can do something like four so actually let's go with J 4J in range 5 like that and now we have a nested list comprehension and if I run this code you can see that now we get a bunch of lists that contain five different values inside of them 10 times okay so that's one thing you can do another thing that we can do here is the following so let's go here and say I for I in range 10 and then we can put in if statement and we can say if I mod 2 is equal to zero now this means we're going to only put this value here if this condition evaluate true so in this case we're only going to put even values or 0 inside of this list so when I run this you see that we get all of the even values up to but not including 10. all right so the next concept here is the different python argument and parameter types now there's quite a few that's why I'm going through this concept and a lot of times people have no idea what they are beyond the basic ones so if we Define a function here like complicated function we can have what's known as our necessary parameters or our positional parameters that are defined in order so I can have something like X Y now these are required and they are positional meaning that if I want to pass values here I have to do something like 1 2 right I pass them in the order in which I want them to be um kind of assigned so X is 1 and Y is 2. however I can actually switch things up a little bit here and as I pass these arguments I can do something like Y is equal to 2 and X is equal to 1. and now if I go here and print this so X and Y you see that we get one and two so this is valid when you are calling a function you can actually write out the name of the parameter whether or not it's positional optional Etc and then you can just assign it directly inside of here this allows you to no longer pass this positionally however if I pass some positional arguments so let's say I do something like one now I can do something like Z2 Y is equal to 3. so I can pass some of the arguments positionally and then some of them I can pass uh using the kind of keyword argument here or you know the named argument whatever you want to refer to it as by the way inside of your function call you refer to these as arguments and up here in your function you refer to these as parameters so I just wanted to show you that I can pass some of these positionally however things get a little bit weird if I try to pass some positionally and some using the keyword so in this case I have like Z equals 2 1 and then y equals three if I try to run this notice I get an error and it says a positional argument follows a keyword argument which you're not allowed to do so if I want to use some positional arguments and the rest keyword arguments that means that I need to start by defining my positional arguments then I can do the keyword arguments after hopefully that's clear but that was the first thing to go over okay next thing is optional parameters so inside of your function you can mark one of your parameters as optional by putting in equal signs by do Z equals two in this case none now this is optional meaning I'm not required to pass it when I call this function so if I call with 1 and 3 here you can see this is perfectly fine however if I got rid of the equal sign here so I made this no longer optional then I get an error and it says it's missing one required positional argument okay that's worth noting now if I try to access Zed here you'll see that actually let's make it equal something like 10. if I run this it actually gets its default value so when you make something optional really what you're doing is providing a default value for it which means if you don't pass that value when you call the function by default it will be equal to that value okay so that was actually the easy stuff now we move on to the more complicated ones now we have something referred to as asterisk arcs now what this allows us to do is actually accept any number of positional arguments so I can pass a bunch of arguments like this okay I can pass no additional arguments I can pass one two whatever it's any number after my positional arguments so if I print out x y z and then args here and I run the code you see that this is perfectly valid so when I do this asterisk args again this means okay I'm going to accept any number of positional arguments at this point so after my two positional arguments that I have here and it's going to store all of them in a tuple which is an e-mutable type okay if we just have star args here then you see it works the exact same way we accept any number of positional arguments even zero right so if I have none here this works perfectly fine okay that is star args now we also have star star quarks so when you have star star quarks this means we're going to accept any number of keyword arguments so let me just print out quarks here and go and pass some keyword arguments so the keyword arguments are like this something like x equals one s is equal to I don't know hello B is equal to True whatever let's do a capital true here so now if I run this you see that we have no positional arguments but we have these three keyword arguments and they are stored inside of a dictionary so if I want to access any of these individual keyword arguments I go quarks and then I reference whatever the key is so I want to reference X here and notice I get one okay this is useful when you want to make your functions Dynamic and you don't know how many regular arguments or keyword arguments are going to be accepting now you can obviously pass both so if I do something like one two three and then some keyword arguments here you'll now see that we'll get both args and quarks having some values and then we can process those values however we see fit okay great last thing to show you is how to use these uh with inside of your function so let's swap this around out and let's say we have like a b and then C is equal to True d is equal to false okay now if we go here we can actually use the asterisks to kind of break apart a list and pass different positional arguments so let's have a list here and I have one two three inside of it and these are actually the corresponding values for both a b and not C Just A and B if that's the case I can't just pass this list because if I do that it's going to be the positional argument for a so what I can do is put an asterisk before it and this is actually going to kind of decompose or break this apart into two individual positional arguments so if I go here and I print my a and my B and I run this notice I get 1 2 works perfectly fine okay now we have the same thing we can do with our keyword arguments so let's say I have a dictionary that contains my keyword arguments something like C is I don't know hello and D is cool I can actually place a dictionary here and then put two asterisks before it and what this will do is break this dictionary into its keyword arguments and pass that to the file function so now I can print C and D and when I have a look uh what does it say here C is not defined sorry we need to just add a string here always forget that you need to do that in Python let's clear and rerun and notice now that we get the values for our keyword arguments so the next concept here is if underscore underscore name equals underscore underscore main now this is simply telling you if you ran the current python file the reason why it's important to understand that is because a lot of times you can have a bunch of different python modules and sometimes you run the module directly other times it might be imported by a different module so let's have a look at this example in this case we have start.pi we have some function and then we have this if underscore under square name equals equals underscore underscore main we're printing run then we have another file here inside of this file we import the add function from this start module now if I didn't have this line here what would happen is when I import this module by default python would read the entire kind of block of code here the entire file and if I didn't have something inside of the if statement so I just had to say print run here then it would actually execute that line of code which I might not want to happen unless I'm actually inside of that module or sorry not inside of that module but if I ran that module it's better if I just show it to you so if I go here and I run pythonstart.pi you see that we get run printing out to the screen however if I run my other file so python other file.pi notice it doesn't print out run however if I remove this line here and we remove the indentation now it will print run so the purpose again of having this line is to determine if you ran this file drag directly a lot of times you have a file where it has a ton of utility functions that are going to be imported by other files and then you have something you might want to do when you're running it directly like maybe initializing a game or starting some program or sending an API request whatever it may be but you don't want this event to occur you don't want this code to run if it's being imported only if it's being ran directly so that's how you use this that's pretty much all you need to know hopefully now you know so the next concept to go over here does not involve my computer and this is the Gil or the global interpreter lock now this is exclusive to Python and essentially what this says is that any thread that wants to be executing needs to acquire The Interpreter lock now what that kind of technically means for you is that you can only execute one thread at the same time even if you have multiple CPU cores on your computer now to better illustrate this because I'm sure it's a bit confusing on your computer you have a CPU or in your computer you have a CPU that CPU will typically have multiple cores two cores four core eight cores whatever it may be now each one of these cores can execute one operation at a time with hyper threading and virtualization you might be able to do a few more I'm not going to talk about all the details there for Simplicity let's say each CPU core can execute one operation well this is great because that means your CPU can be working on multiple things at the same time and if you have a complex application it's possible that you want to be doing something like processing an image while allowing a user to type something in while maybe sending a request to the network there's a ton of different things you could be doing at the same time and this is where multi-threading comes in a thread is essentially a component of your application that's being executed by the CPU when you start getting into larger programs you start designing multi-threaded applications where you have different pieces of your code separated into different threads such that they can execute at the same point in time now with python you can do this you can have multiple threads the issue becomes though that you have this Global interpreter lock now what that means is even if you have a bunch of CPU cores on your computer only one of these threads can be executing at a time that's because this thread needs to acquire something known as a lock on The Interpreter now I'm not going to discuss why this was implemented in Python but what you need to know about this is that if you do actually have multiple threads this is not going to give you a performance bonus in Python it's not going to increase the speed at which you execute your code so to give you a simple example here let's say I wanted to sum the numbers from 1 to 100. well if I was doing this in a single thread I'd have to sum all of the numbers from 1 to 100 in a row however what could be more efficient is if I split this into four threads or six threads or eight threads and I summed sections of the numbers for example if there was four of me then I could sum the first 0 to 25 25 to 50 50 to 75 75 to 100 and then I could add all of those values together and this would allow me to sum the numbers four times faster and in a traditional programming language you can do this you can create four threads they're going to be executed on four different CPU cores and this will allow you to very quickly speed up your programs using these multiple threats in Python you can't do that even though you have these multiple threads only one of them can execute at a time which means it doesn't matter how you split these things up it's going to take the exact same amount of time or approximately the exact same amount of time to execute this code now I'm going to stop here hopefully you get the point that you can only have one thread in execution at a time if you know that you pretty much know the global interpreter lock if you want to learn more then I'll encourage you to read about it or let me know in the comments if you want to see me make an entire video on it regardless I'm going to wrap it up here I hope that you found this helpful and I look forward to seeing you in another YouTube video foreign [Music]

Original Description

See NordPass Business in action now with a 3-month free trial here http://nordpass.com/techwithtim with code techwithtim GET MY FREE SOFTWARE DEVELOPMENT GUIDE👇 https://training.techwithtim.net/free-guide If you're interested in becoming a developer that writes any type of code in python, then you need to understand these 5 Python concepts. In today's video, I'm going to break down 5 key Python concepts for any aspiring developer. Master Python, elevate your skills. 🎬 Timestamps 00:00 | Introduction 00:38 | Sponsor 01:43 | Mutable vs Immutable 06:20 | List Comprehensions 08:22 | Function Argument & Parameter Types 14:44 | if __name__ == "__main__" 16:34 | Global Interpreter Lock (GIL) ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️ 👕 Merchandise: 🔗 https://teespring.com/stores/tech-with-tim-merch-shop 📸 Instagram: 🔗 https://www.instagram.com/tech_with_tim 📱 Twitter: 🔗 https://twitter.com/TechWithTimm 🔊 Discord: 🔗 https://discord.gg/twt 📝 LinkedIn: 🔗 https://www.linkedin.com/in/tim-ruscica-82631b179/ 🌎 Website: 🔗 https://techwithtim.net 📂 GitHub: 🔗 https://github.com/techwithtim One-Time Donations: 💲 https://www.paypal.com/donate?hosted_button_id=CU9FV329ADNT8 Patreon: 💲 https://www.patreon.com/techwithtim ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️ ⭐️ Tags ⭐️ - Tech With Tim - Top 5 Python Concepts - Master Python ⭐️ Hashtags ⭐️ #techwithtim #top5python #pythonprogramming
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video teaches the basics of Python programming, including data types, list comprehensions, and threading, and provides examples and exercises to practice these concepts. It also covers the Global Interpreter Lock and its impact on multi-threading in Python.

Key Takeaways
  1. Define immutable and mutable types in Python
  2. Explain the difference between immutable and mutable types
  3. Use list comprehensions to simplify code
  4. Define a function with positional and keyword arguments
  5. Pass positional arguments to a function
  6. Pass keyword arguments to a function
  7. Use the * operator to unpack a list and pass different positional arguments
  8. Use if __name__ == '__main__' to determine if a file is being run directly or imported
💡 The Global Interpreter Lock in Python prevents multiple threads from executing at the same time, which can impact the performance of multi-threaded programs.

Related Reads

📰
The Secret Sauce of Apple Silicon: Why Unified Memory is a Game-Changer for AI If you’ve spent…
Learn how Apple's Unified Memory boosts AI performance, especially for large language models and generative AI, and why it's a game-changer for professionals
Medium · Machine Learning
📰
The Secret Sauce of Apple Silicon: Why Unified Memory is a Game-Changer for AI If you’ve spent…
Learn how Apple's Unified Memory boosts AI performance, especially for large language models and generative AI, and why it's a game-changer for these applications
Medium · NLP
📰
The Silent Killer of Edge AI: How to Master Thermal Throttling and Prevent the "Performance Cliff"
Master thermal throttling to prevent the performance cliff in edge AI by optimizing your model and hardware configuration
Dev.to · Programming Central
📰
We Gave Our Engineering Team a Memory — Here’s How PRECOG Uses Cognee
Learn how PRECOG uses Cognee to build predictive engineering intelligence and enhance their engineering team's capabilities
Medium · Startup

Chapters (7)

| Introduction
0:38 | Sponsor
1:43 | Mutable vs Immutable
6:20 | List Comprehensions
8:22 | Function Argument & Parameter Types
14:44 | if __name__ == "__main__"
16:34 | Global Interpreter Lock (GIL)
Up next
Copilot Cowork: Setup, Skills, Plugins & Pricing
Matt Tutorials
Watch →