- Welcome to Python Fundamentals part three of five.
My name is Paul Deitel and I'll be your instructor
for these LiveLessons videos.
Part three is based on chapters eight through 10
of our textbook, Intro to Python
for Computer Science and Data Science,
learning to program with AI, big data, and the cloud,
and also chapters eight through 10 of our professional book,
Python for Programmers.
The prerequisite for part three are either
Python Fundamentals LiveLessons parts one and two,
or equivalent Python programming experience.
Many people find that as they work their way
through the videos, it's helpful to have a copy
of the book at hand.
However, this is not required.
There is additional information in the books
that I don't cover as part of these videos.
If you're interested in getting a copy of one of the books,
you can find them in various print and electronic formats
at the sites that are listed for you.
If you're a college instructor,
you'll probably want to take a look
at Intro to Python for Computer Science and Data Science,
which is our college textbook version of the book.
This one is in full color, it's 880 pages,
240 pages more than Python for Programmers,
and in particular, it contains a ton of exercises,
557 self-check exercises, as well as 471 additional
end-of-chapter exercises and projects.
Now many professionals find that
they like to work with the textbook version,
specifically because of the exercises.
If you're interested in learning more
about Intro to Python for Computer Science and Data Science,
please take a look at the links that I've provided below.
The first one is for an architectural diagram
in which we show you the four-part
modular structure of this book,
and that really applies both to the college textbook
and our professional book, Python for Programmers, as well.
The for programmers book has one fewer chapter,
but the overall architecture of the two books is the same.
And also, in the for programmers book,
we have less of the lower-end pedagogical material
that's really geared to people
who are novices in programming.
The second link is for the full table of contents,
where you can see everything that we're going to cover
throughout the book.
And the third one is the book's preface,
where you can learn more about our approach
to teaching Python, data science,
artificial intelligence, and various big data topics.
I'd also like to recommend that you take a look
at these two additional links.
The first one is for the full book cover.
And in particular, if you look at the back cover copy,
you'll see a nice summary of everything
that we're going to do throughout these LiveLessons videos.
And I'd also recommend that you take a moment
to read through the technical
and academic reviewer testimonials
to really get a sense of all the things
that they liked about how we presented Python
and the various data science, AI, and big data topics.
To begin this lesson, we'll take a look at lesson eight,
strings, a deeper look.
Now because Python is a scripting language,
it is frequently used in all sorts of
string processing capabilities.
So as we go into lesson eight here,
we'll be looking at a lot of little individual details
of how to work with strings in Python.
We'll take a look at various string methods,
look at how to do various
string formatting capabilities as well.
And as part of that, by the way,
we're going to be not only talking about
the F-string concept that you saw
in some of the earlier lessons
for creating formatted string content,
but also looking at an older style of string formatting
that you will frequently encounter
in other people's Python programming code.
And of course, Python has been around now
for an extremely long time.
So it is important for you to have a sense
of other ways of doing things,
even if they're not the most current, as well.
One of the key aspects that we'll be looking at
for string processing in this lesson
is Python's extensive set
of regular expression processing capabilities.
And we'll introduce a variety of those
as part of this lesson,
and then start to use those a little bit more
as we move into the intro to data science section,
where we will continue our discussion
of the pandas library from lesson seven in part two.
But we're also going to use pandas now
to perform some data manipulation and data preparation.
And we'll combine the regular expression concepts
that we learn with pandas to do that.
In lesson nine, files and exceptions,
we're going to take a look at several different file formats
and introduce Python's version of exception handling.
With respect to file processing,
we'll look at basic text files for both input and output.
We'll also take a look at the very popular
Java Script Object Notation, or JSON for short.
JSON is one of the most popular data interchange formats,
and we'll be using that extensively in subsequent lessons.
So we want to introduce it to you here
in the context of writing Java Script Object Notation,
out to a file on disc, and also reading data back in
from such a file as well,
and turning it back into a Python object.
Now we're going to get in depth
into the Python exception handling mechanism.
And if you're coming into this videos
from a language like C++, or Java, or C#,
you're going to see a lot of familiar concepts.
Python uses some different key words
and also has some additional concepts
that you won't find in those other programming languages.
So I'll be sure to point all of that out to you.
Now when we get to the intro to data science section
in this lesson, we're going to focus on
comma separated value files.
And one of the key reasons for that
is part of our focus on processing data sets
in a lot of the higher-end lessons.
Many of the data sets that you will work with
are provided in comma separated value format,
so it is important to know
how to get such data into an application,
and sometimes how to write out such data as well.
So in the context of both the CSV module
that's built into Python, and the pandas library,
we will be showing you how to load and store
comma separated value data.
To finish up part three, we'll take a look at lesson 10,
object-oriented programming.
Now over the course of a year and a half
of research for this project,
as I mentioned in an earlier lesson,
we rarely encountered the need
to create custom class definitions.
In fact, I think for the project,
we wound up creating only four or five or six of them total,
outside of lesson 10, where we show you the mechanisms
for creating your own new data types in Python.
So the vast majority of Python programming is done,
as what we like to refer to, as object-based programming,
where you create an object of an existing class,
probably imported from one of the many
open-source libraries that are out there,
and then you interact with that object.
In lesson 10, we focus on how you can create
your own new custom data types.
So for instance, if you're creating a library
that other people are going to use,
a lot of what I present here in this lesson
is going to be relevant to you.
If you are going to need to create any custom classes,
which we do a few times in some of the subsequent lessons,
you'll probably find that you can look at
the classes we defined and figure out what they do,
if you are already an object-oriented developer.
If you are not, however, I will cover
object-oriented programming in detail here in lesson 10.
Some of the things that we'll be looking at
are how to create custom classes,
how to use a concept called properties
for accessing data inside of an object.
And by the way, one of the things
that you're going to find in Python
is that its approach to object-oriented programming
is a lot different from languages like C++, Java, and C#,
which all have concepts of what we call public,
protected, and private members of a class.
In Python, everything is public no matter what you do.
So one of the things that we're going to do
is look at Python's conventions
that Python programmers follow
to indicate aspects of a class definition
that should not be used by somebody
who is a client of the class.
So you create an object, you interact with that object,
but there's still specific attributes and behaviors
that you should be using to interact with those objects.
And there are others that are meant for internal use only.
And in Python, internal use only is done
with naming conventions, not key words,
like public, protected, and private.
So we're going to talk about those issues
and show you how you can simulate the concept of private.
But even those things are still publicly accessible,
as I will demonstrate to you throughout this lesson.
Some of the other things we'll take a look at here
are how to create new classes from existing classes.
So we'll talk about inheritance
and polymorphism capabilities,
and you'll see that those are very similar to some of
the C-based object-oriented programming languages.
We're also going to introduce a really key concept in Python
known as duck typing.
So basically the idea is if it looks like a duck,
and it walks like a duck,
and it makes the same sounds as a duck, it must be a duck.
So basically in Python, when you pass an object,
for example, into a function,
as long as that object has the capabilities
the function expects it to have,
the function will be able to
interact with that object and use it.
So for instance, a lot of the visualization libraries
expect you to provide objects of the numpy array data type.
But because Python lists have a lot of
the same capabilities as numpy arrays,
you can often pass in a list where an array is expected.
Some of the other things we'll look at
are additional syntax features like operator overloading,
where you can create your own new operators
to work with your custom data types.
So for instance, if you wanted to create
some new mathematical type,
you could overload the plus operator and the minus operator,
and the multiplication operator, et cetera,
so that you can use objects of your type
as conveniently as using integers, for instance.
We'll talk about a concept called named tuples,
which are tuples where you can access the elements
by their names instead of by index numbers.
We'll also introduce a relatively new feature to Python
that was introduced in Python 3.7 called data classes.
And we'll show you some unit testing capabilities
that are built into the Python standard library as well.
In the intro to data science section,
to finish up part three, we're going to start to
take a look at some more data sciencey stuff.
In particular, we're going to look at time series
and a concept called simple linear regression.
And this will be our first introduction
into some of the topics that we're going to start to see
in more detail in parts three and four.