How to learn Python in 2021 - Roadmap to Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Hey Everyone 🍻,

I made a getting started with Python Roadmap! This video is basically a summary of all the things I think is important to know as a beginner when getting started with Python. It is also a good review for those that have been working with Python for a while but are unsure if they are missing "something".

My goal of this video was instead of doing a long 5-hour tutorial going over strings, datatypes etc was to instead give a high-level view of everything that I would expect a Python Engineer to know. This is something that I wish I had when I was getting started - as I already have programming experience but wasn't sure about all the nuances of Python.

I also created a cheat sheet of everything I go over in the video:

📝 Cheatsheet: https://devopslifecycle.com/roadmaps

👍︎︎ 4 👤︎︎ u/DevOps-Journey 📅︎︎ Mar 30 2021 🗫︎ replies

Not sure how this video is a roadmap, just some random topics together plus "2021"

👍︎︎ 1 👤︎︎ u/riklaunim 📅︎︎ Mar 31 2021 🗫︎ replies

nice

👍︎︎ 1 👤︎︎ u/SquigglyGamba 📅︎︎ Jun 16 2021 🗫︎ replies
Captions
what's up everyone this is brad from devops journey and today we're going to talk about the key components that you need to understand when learning python so this video is going to be really great for people that are just getting started with python but not only that it's going to be good for people that have been learning python for a while but are unsure if they're missing any key concepts so this video does include chapters so if anything that i go over seems too elementary to you feel free to use the chapters to skip ahead to the section that's relevant to you don't worry you're not going to hurt my feelings or anything like that just go ahead and smash that like button to make it up for me so without further ado let's get started at level 0 which is the basics of your python environment so for the very basics we have the python interpreter python 2 versus python 3 we have the id le we have pip and we have coding environments so let's go ahead and start off with the python interpreter python is an interpreted language this means that for every machine that needs to run python code they need what's called the python interpreter you can download this from python.org and install it on your machine and is compatible for windows mac or linux so python 2 versus python 3. this video is made in 2021 so chances are you're going to be using python 3. however you're still probably going to run into python code out in the wild python 2 was wildly popular and there's still a lot of libraries that are dependent on it another thing that might catch you off guard is when you type in python it might run the python 2 interpreter instead of python 3. so you need to be aware of the python interpreter that you're running and it's going to run the code differently if you run the python2 interpreter versus if you run the python3 interpreter the idle this stands for the integrated development learning environment this is a great tool that we use as python developers basically this is the python console where we can go into and we can write any python code this is really great when you're testing things out and you're just sort of experimenting with python as someone that works with python every day i can tell you that i always have the id le up and when i'm running code i'm constantly testing things in this python console just to sort of experiment and test things out and troubleshoot my own code pip stands for pip installs packages and that's exactly what it does this is python's package manager for going out and downloading python package libraries python is what we call a battery's included language this means that there's literally thousands of python libraries out there that you can use in your own code almost any python script that you run is probably going to use a python package of some sort to install a package with pip do a pip install and then the package name if you're downloading python code from a repository like github you may notice that sometimes it's packaged with a file called requirements.txt this requirements file has all the python packages required to run that python script if you want to install all the python packages in the requirements text file simply go pip install dash r and then requirements.txt this will go through each of the packages in the requirements text file and download and install them you can create python code without using a fancy code editor but it's always good to start off on the right foot although there's a lot of different code editors to choose from and there's no best choice the ones that i see use most frequently are vs code and pycharm my personal preference is to use vs code but pycharm is still widely popular in the community python uses indentation to indicate the start and end of code blocks this is one of the beautiful things of python in most coding languages you're going to indent your code anyways as a best practice there are more rules for python syntax but they're best summarized in the python enhancement proposal pep 8. pep 8 is the de facto styling guide for python so you're going to want to give it a read but if you don't like reading you can go ahead and google pep 8 song for a catchy tune data types so data types are arguably the most important thing that you need to understand when it comes to python applications are really just a flow of data and being able to capture that data and store it into the proper data types is half the battle when it comes to python the four most important data types that you're going to need to understand are strings integers lists and dictionaries integers are python data types that you can perform math functions on lists are python objects that can contain multiple different values a list is contained in square brackets and is separated with commas dictionaries are python's versions of key value pairs for every dictionary key there will be a value associated with it now one thing that you should understand when it comes to data types is that they can be nested into each other you can have lists of dictionaries and you can have dictionaries that contain lists you can also have lists of lists of dictionaries and dictionaries of lists that contain lists of dictionaries of lists and lists of dictionaries of lists of lists that contain dictionaries that have lists and yeah it gets a little crazy anyways knowing these data types and how to store them into variables is something you're going to want to know when you're working with python the next important thing to understand with python is the control flow mainly if statements for loops and while loops we have the if if else an else statement basically if a condition is true it will perform a block of code if another condition is true it will perform that block of code and if nothing is true it will perform that last block of code we have four loops which iterate through a list of items and executes a block of code for each item in that list the last one is while loops basically the code within a while loop will execute as long as the condition is true if the condition is ever not true then the code will stop executing just be aware that when you're using while loops you could potentially create a loop that never stops executing this brings us to operators most importantly comparison operators these operators are used to determine if something is true or false and are used in conjunction with your if statements and while loops the last thing that i consider a level one skill is how to accept input from a user there's usually two ways of going about this you can either take in arguments when the user types in the python script your other option is to make use of the built-in function input this allows you to prompt the user for user input at any point in your application level two so at this point you should be able to build a basic python script let's level up your skills further by talking about object methods in python everything is an object and these objects have methods that you can make use of common methods that you should learn to use when you're starting out with python are string methods list methods and dictionary methods one example of a string method is the capitalize method this will capitalize the first letter within a string but methods can be a lot more powerful than just capitalizing a string an example of a more powerful string method is the method split this allows you to split a string into a list this can be extremely powerful as a lot of the data that you take in might come in the format of a string but you need to iterate over it like a list you can use the split method on the string to separate that string into a list a common method used for lists is append this allows you to add an item to the end of a list a common method used for dictionaries is get this allows you to get the value of a dictionary key built-in functions so these are functions that are already built into python we talked about one of these in the last section the built-in method input allows you to take input from a user there are many other built-in functions that come with python and a lot of them are very powerful ones that i find myself commonly using is help der vars and type slicing when you first get into python this is going to be something that you have to spend some time on like i mentioned before working with data in python is half the battle being able to properly extract the data from your lists and strings is going to be extremely beneficial let's have a quick look at how it works alright so quick tutorial on slicing here since slicing is such an important topic i thought i'd go pretty in-depth here so to start us off we have the string devops and i'm assigning it to this variable my string and then at the bottom here you can see how i'm slicing the string up so let's go ahead and copy this into the terminal and i'm going to start this off by going my string and then i'm going to put square brackets and then i'm going to put a colon and it prints out everything by default if you don't indicate a number but what you can do is indicate start and stop positions if we run this again and then we leave the start one blank and then we say we want to stop on character number three you can see that it prints out the first three characters and a good way to visualize this is this little diagram that i drew up here and there's positive and negative numbers up here and what these numbers are representing is just the position of the character so at position zero we have d and position one e and it just sort of goes up like that so what it's saying is print everything up until position three so zero one two which is dev and that's why we print out dev now if we do this again and we say we want to start at position 3 and print until the end you can see that it prints out ops so it's starting here which is o and it prints out ps and it just sort of ends there because that's the last position and you can also indicate both a start and stop location in the same slice so we could say slice between characters two and five and if we have a look here we can see this is two up till five so it should print out v capital o p so hit enter and you can see that's exactly what it printed so that's the basics of slicing now you can see that there's negative numbers here so with negative numbers basically the last position is negative one and it just goes down from there until you get to the very end so if we wanted to print out ops for example we could go here and say we want to print out from character negative three and just go until the end you can see you can do it that way as well so that's your basic rundown of slicing and keep in mind you can do this with lists as well functions functions are block of code that run only when they're called functions can take an input perform actions and return the result of those actions anytime that you have code that repeats itself you should be using a function this follows the drive methodology which stands for do not repeat yourself also one of the benefits of using a function instead of just copy and pasting your code is when you need to make a change to the functionality of your application you only need to change the code in that one place in your function you don't need to search for every iteration of your code that needs to be changed errors and exception handling sometimes errors happen in your code and don't feel bad for it it's not because you're a bad programmer sometimes errors are expected for example if your script tried to open up a file but that file didn't exist it would exit out of your script and present an error to the user instead of having the python interpreter crash out you could use a try and accept block in your code in this way python can try to open the file and if it runs into any issues it can execute the code within the exception block when it comes to the accept block you can have a general accept statement that accepts all errors thrown at it or you can manually specify the exception that you're expecting this is considered a best practice but i know a lot of the time i just do a catch-all accept statement modules as i mentioned before contain powerful python functions that we can use as the building blocks of our python scripts to access the power of these modules we first need to import them into our python code to do this simply type import and then the module name if you only want to import a specific function of a module you can do that as well you can also import functions with an alias name an example of this is importing pandas as pd now when we want to reference pandas in our code we can reference it as pd instead of pandas working with files is a common operation in python and you should be familiar with it a good practice of opening files in python is with the with statement you can open the file as read write or append you can then perform operations on the file like reading in lines or writing outlines to the file when the with code block is done executing it closes out the file handle for you if you don't use the with statement when opening files then you're going to have to handle the logic of closing out the file handles yourself so this is why it's a best practice to use the with open code block so level four this is when you should start familiarizing yourself with the popular python modules that are available to you no matter what your code is trying to accomplish it's highly likely that there's a python module out there that can help you it's a terrible feeling to spend three or four hours writing code to find out that you could have solved that problem with the python module the popular python modules that i recommend that every python engineer have in their arsenal is os cis requests regex pandas and logging the os module is responsible for giving you access to the underlying operating system things like listing all the files within a directory or returning the hostname of a system the sys module the sys module gives you access to some variables within the python interpreter a common function used within the sys module is the rgv function this allows you to have access to the arguments that the user specified when they ran the python script requests request is a python module that allows you to send http messages this is going to be a popular module for you devops engineers that need to create web scrapers or work with restful apis regex so i hate to be the one to tell you this but at some point in your programming career you're gonna have to make use of regular expressions and the best way to do this in python is to use the regex module regular expressions are powerful tools that we can use in our application to search and find data the syntax for regular expressions can be daunting at first but you get used to it as you write them out with a little bit of practice you too can be a regex expert pandas is a data analysis tool pandas to a python engineer is like excel on steroids it's used a lot in the big data and machine learning world but i find myself using it all the time in my own scripts it's a great way to work with and display large sets of data and they make it very easy to export that data into excel or a comma separated list logging logging is super easy to implement in python and it makes your application look very professional all you need to do to implement logging into your application is import the logging module set a few parameters and then you can start sending logging messages to the user or to a log file if you want to learn more about how to properly set up logging check out my video on python logging level five so now that you know how to write python code it's time to get familiar with the tools of the trade the tools of the trade that i'm going to mention in this section is get github pipe and virtual environments get is a tool for tracking changes in a set of files more specifically it's used to track changes that someone makes in their code it's a tool universally used by all programmers and you should get very used to it you really only need to know a few simple commands to get started with git after get comes github which is the repository that you can store your code in although github isn't the only code repository to choose from it's probably the one that you should start off with pi pi is the python package index basically it's an index of all the publicly available python packages when you type a pip install and then the package name it's going out to pi pi to find the package and pull it down you can use pi pi to explore all the publicly available python packages and you can even publish your own virtual environments as you start working with more python scripts you're going to notice that they have different package requirements some of your scripts may use the same package but it might require a different version this is where virtual environments come into play to manage your scripts with different package requirements you can simply create a virtual environment for each of them to create your own virtual environment type python dash m v e n v and then a virtual environment name after that run the activate script and you'll be in your python virtual environment this new virtual environment will be like starting off on a blank slate you can then install any of the packages that you need to onto this virtual environment just by going pip install and then the package name remember if the code you have has a requirements file you can install all the requirements by going pip install dash r requirements dot text okay so now you're a level five python programmer what's next well the next things that i would consider learning more about is object oriented programming classes design patterns comprehensions dunder or magic methods lambda functions and decorators i'll try to do another video on these more advanced topics in the future but until then you can go out and research them if you would like to anyways i hope this video has been helpful to you i've left a cheat sheet for python in the description below so make sure to check that out and if you haven't already please hit that like button anyways thanks again for watching and i hope to see you all in the next video [Music] you
Info
Channel: DevOps Journey
Views: 6,352
Rating: 4.9822221 out of 5
Keywords: python developer, python tutorial, python roadmap, python roadmap 2021, how to learn python 2021, how to learn python, learn python, python career path, python developer skills, how to become a python developer, learn python programming for beginners, python developer day in the life, python developer roadmap
Id: jEUjcEIrEa4
Channel Id: undefined
Length: 18min 5sec (1085 seconds)
Published: Tue Mar 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.