[MUSIC]
So, hopefully this gets you started with Python, the programming language
with the iPython Notebook, and a little bit of iterating the console.
We're gonna be using this console again and again, it's really a fun,
simple way to manage and interact with data.
And there's also tools for visualizing, for navigating, for
doing machine learning in this Python space.
So, it's really a great programming language for us.
And, in fact, there's been a lot of surveys
that say most recently Python is the programming language for data science and
that's why we picked it for this course.
As a final step, let's talk about creating functions in Python.
It's actually pretty easy to create a wide range of functions within Python and
it's pretty natural.
So there's two ways of doing it.
So let's go ahead and get started.
So, again ask m for a text box and
we're gonna talk about
creating functions in Python.
Okay, so the first way is using the def command.
So this is defining a function, let's say a fun function,
add 2 which takes an element x and adds 2 to it.
So we write def add2, and in parenthesis, you put the number of parameters you have,
there is this x, you could have x, y, z, and so on.
And then you put a colon at the end.
And just like with flukes, we want to align in vertically,
kinda tabulated, until we've written out all the function we want to do.
So for example, we could say y is equal to x
plus 2, and then we say return y.
So here we defined a function add 2.
So let's, remember integer value i, let's just set it to some number,
let's say we say that i is equal to 5, and we say
add 2 with the input i and we get 7.
Voila.
The second way to define functions is using what Python calls lambda's, and
these are for simple functions and it's useful to know it.
It's used in a variety of places where you just do a simple transformation,
even add to is a simple transformation so for example,
let's create a function called square.
So this is the square function,
which is a lambda that takes into input x and returns x times x.
So if I read this to you when defining a function, this land is a function,
takes x's input and returns x times x.
That's what it tells us after the column.
So we defined that and now we can apply square to anything we want, so
for example.
If we say what is the square of 3, it should say 9 and
there we go, two ways to define functions in Python.
Now we have the grasps of Python's basics, they can used for
all assignments we're gonna be building up in this first course.
[MUSIC]