profesor profesor profesor it's time for all of python in 10 minutes
hello howdy and welcome if this is our first time meeting thank you so much for
tuning in to data leap where we'll bring the data science world down to earth we
want to help you become a data scientist with very digestible pieces of videos
that share how easy it is to break through and beyond by the end of this
video you'll have taken a crash course in Python that will get you as far as
you need to do data science the right way check in the description below if
you want to check out this time stamps for each individual Python concept if
you want to pick up somewhere in the middle or pick up somewhere all the way
at the end and go backwards this course is not just for people who are
interested in data science learning a coding language in this day and age is
as important as learning to tie your shoes you could do without but you won't
get very far this will be Professor meatballs custom course that has given
him stunning reviews such as this was the encapsulation of four years of my
undergraduate degree this was the encapsulation of two years
of my master's degree this was the encapsulation of all of the Python I've
ever used in my 30 year work history Thank You professor meatball so so so
much I love you you're such a good boy
that Big Timers about to go on so just before we start remember that we covered
how to install Python and Conda in the last tutorial please check it out we'll
have a link right above and professor meatball asked me to ask you guys if you
like this video go ahead and give it a big thumbs up so we get some feedback of
exactly what you guys are looking for and how we can continue to help you
achieve your goals and without further ado let's get started what I was able to
sneak into that intro just then was installing Jupiter lab which you'll see
the command right up top I'll make sure that these commands are not only on the
top of the video but also within the description so you can copy and paste
make sure that you're inside your environment with Conda activate and jump
on into JupyterLab that's the command that we'll put in to
activate our IDE for me that's opened up in Chrome this will open up in your
default browser you'll see that we're here at a terminal just like before it
DejaVu let's build an entirely new sandbox folder CD into that sandbox
folder and go ahead and press this plus sign and start our first notebook if
your notebook doesn't look like this and you want the dark setting go out and go
to settings and then Jupyter theme dark so your very first notebook let's title
it: myfirstnotebook. and we're one minute in which means it's time for hot secret tips about how
to run your notebook smoothly for a data scientist efficiency is everything so
you need to remember an easy acronym enter escape app the data enter is how
you get into a cell to input text escape is how you get out of the cell and press
either A or B to put a new cell up or below the cell that you're currently in
finally D D press the D key twice to delete the cell that you're currently
selecting you must be outside the cell with escape
finally to differentiate between code and not code we can comment with a
hotkey make sure you're holding down control and press the forward slash
button it is the same button as the question mark button and just know that
you can also press it again to uncomment commented code will not run which
sometimes makes debugging a nightmare something you can find above and the
momento sketch where debugging is living hell coming in at 2 minutes let's start
with types we have an integer 1 and 2 point 0 that is a floating-point number
these are the two types of numerics inside Python you notice that two point
is also in loading point number and math is the same as it is in the math
classroom just note that every time you divide you will get a floating-point
number no matter what integers will not come out a quick reminder to use
parentheses for order of operations and we move on to assignment here we'll we
have a variable called a I'm putting the value two into it now B
is also to adding a and B together but turns the values of a plus B which is 4
and we can reassign a's value to 3 now a plus B equals 5 in fact if we go up to
the cell that we ran before it is also 5 be really careful when you're signing
and reassigning values of variables let's just round out math real quick we
have 2 to the power of 2 which is just asterisk asterisk and we can have the
square root of 2 which is 2 Astra's astrick 1/2 the 3-minute mark means
that's time for strings now it's a good time to tell you about protected
variables if you try to do STR you'll notice that it glows in green anytime
this happens python is protecting this variable so do not try to use it for
assignment let's have our first string the hello world as appropriate and we'll
use the print statement to return it to a console for example if you're running
a .py file you'll be able to see it out inside your console and you guys
know my catch phrase strings are just an amalgamation of letters these are actual
lists of individual characters that we can index through indexing is synonymous
with picking exactly which part of the string you want starting at what point
stopping at what point and how if at all do you want a step or skip it's 1 by
default but you can use 2 for every other element and so on and so on
notice that the D is miss and that's because stop does not include that
element which we put as negative 1 the last element the four-minute marker
means that we now concatenate strings this means putting two strings together
you'll notice that I can put my name as data lead and make sure to put a comma
there and they output together this goes back to the catch phrase that
strings are just what amalgamations of individual characters you might be
asking if I needed a string that had an apostrophe inside like ain't you proud
of me pod that it would ruin the string as you can see from the coloring you can
use double quotes and still use a single quote inside it or the opposite double
quotes inside and single quotes outside one last string indexing tip you don't
need a start stop or step if you leave out any of the values they will use the
default values and if you put negative 1 as the step it'll reverse the string
let's see if it works with the palindrome
racecar racecar if you wanted a line-break as in print on a separate
line backslash n will do it for you and I still have race car cool for more
lists like objects let's look at a list of mine this is just three ones in a row
no much of an issue but what if we wanted to have a set instead that means
no repeats no hesitations set cannot have repeated values so it condenses all
the ones into one a list can also have different kinds of types inside you see
that we have a string of integer and a float they all fit inside nicely now
time for dictionaries which can also hold multiple types of objects we have
key value pairs which would also be known as an associative array in other
languages since keys are mapped directly one-to-one with values you'll be able to
index into a dictionary similar to a list except with the key instead of the
position this is a lot more family friendly when it comes to reading other
people's code now let's talk about logic we have a couple of logic operators here
equals equals tests equivalency and we're checking whether 1 equals 1 or 2
equals 1 since the first statement is true that makes the entire statement
true now that we know true and false we can put them into if statements if the
statement is true then you can run the code that is after the if statement here
we've indented it so the code knows exactly what to run but your if
statement doesn't have to be true let's make an incorrect if statement since 1
does not equal 2 we cannot run the code underneath the if statement but we can
run the code underneath the else statement equal equals checks for
equivalency and bang equal this is what we call the exclamation mark tests for
unequivocally if the world was just if in else's that'd be kind of bland
luckily there is an else if or Elif put an elephant in between your first if
statement and your else statement therefore checking multiple conditions
but remember order matters so whichever Elif statement is first true that's the
one that is going to trigger and the rest of it is going to be ignored in
this particular Elif statement we're using an operator called in this checks
if an object is within a list conversely you can put not as a similar bang equal
sign opposite meaning of in this checks of an object is not within a specific
list it's the 7-minute mark which means it's
time to iterate through our first for loop a for loop looks
a list and then for each object in it does something to it here we're printing
each object but the objects are still in the list if you want them out and out
permanently use the dot path method methods are built in Python functions
and you'll notice that if we look inside our list again that particular one point
zero float is now missing but no need for crying over missing variables all
you need to do is a dot append a different method and put in exactly what
you want to add to the list it adds the very back of the list so it
looks like it never changed our detour into the dot pop method was covertly a
way to introduce the while loop this loop
unlike the for loop which iterates through each object in a list iterates
until a specific condition is satisfied here we're checking whether or not the
list of many types is not empty once it is empty the condition is no
longer satisfied which means the loop has to end since we popped every single
element it's empty and barren let's put that list back in there cuz you're not
quite done with you yet let's copy our while loop and make it a little more
interesting let's introduce in concept code format
slap this method at the end of any string and it'll replace any open close
curly brackets that you have in the string with whatever object you have
inside the method here we are printing out what item we're currently popping
and what the current condition of list of many things looks like in the
homestretch let's start our very first function whatever we just did with that
list pop method we can do that down here with this function that we're defining
list popper it takes in an input list which we defined up here I'm just
copying and pasting the code we had and changing the input list now when you run
this function it's not gonna do anything but when you call it with the input list
you'll notice that it's gonna come out with the exact same output as we had
above this makes your code reproducible and much easier to read because you're
referencing code that you wrote already instead of having to repeat it every
time let's make a better version of our list popper this list popper 2 is an
exact copy but we're gonna put an if statement up above in case some rascal
wants to put input into the function that is not a list note that the entire
while statement needs to be underneath the if statement in order for it to run
when the input is a list it works the exact same as the previous function but
if it's not a list it's not a list that's not the only way that Rosco's can
break your code so we need to be even more prepared let's
try a try except block the console will not throw an error if anything goes
wrong under the try block instead it'll run the except block I'm gonna vaguely
say that something happened even though you can tailor make different exceptions
depending on the errors that occur let's try this bad input on all three
iterations of our list popper function the very first function which is throw
the error while the second function knows it's not the correct input we
started with math now we'll go back to math as one of the possible packages you
can import truly the power of Python is within its packages now say that three
times fast fluency with a coding language is just like a spoken language
so now you have the skills to start practice if you're a voracious reader go
ahead and read the documentation to learn more about classes input/output
etc and know that we ended with pi because python is a piece of cake
hey if this was helpful leave a comment for professor meatball so that he can
have office hours and take care of those questions for you to share this leave a
like and make sure to tell us what to do next
we'll have content like this every week something funny and something
educational for now we'll see you next time peace