1. Home
  2. Training Library
  3. Big Data
  4. Courses
  5. Practical Data Science With Python

Object Oriented Programming in Python

Developed with

The course is part of this learning path

Practical Data Science with Python
Start course

This course offers an introduction to data science and looks at what a data scientist does. It then moves on to data science in Python and, through a range of guided walkthroughs, shows you how to use Python and its features. You will learn how to set up Anaconda and Jupyter Notebook and learn, using real-world examples, how to write Python code in Jupyter, with useful tips within the context of data science.

The course also looks at object-oriented planning, as well as Python variables and Python functions, and finally, it takes a look at Python data types and functions.

Learning Objectives

  • Understand data science and the role of data scientist
  • Set up Anaconda and Jupyter notebooks
  • Improve your knowledge of coding with Python
  • Understand how to work with Python variables, functions, and data

Intended Audience

This course is intended for:

  • Individuals looking for an introduction to data science
  • Those looking to enhance their knowledge of Python and its features


To get the most from this course, you should already have some knowledge of Python and programming languages in general.


Hello, and welcome back. Let's now move into object orientated programming. What that means for us in terms of program design probably means less than it does when it comes to working with Python data, Python objects, all those sorts of things. Objects tend to represent things in the world. Commonly, in system design, we would look at an object as a noun in something that we want to build for that system. So, an example of this would be something like a pen. A pen is something that we might want to encapsulate as an object. And what do we mean by 'an object'? An object is something which has an internal state and a set of actions associated with it. It's okay, we're talking about object orientation. So, what are the details about this, about pens? Well, we can say, we have a pen, this is our pen here, and this pen is just red. So, we can also say that it can write on a whiteboard, so, it has the ability to write, and we could also say that it is perhaps a thick pen. So, a thick, red pen. There, thick. We can also say that it is made of plastic. So, let's put that on there as well, and then, what else can pens do? Let's say that this pen can also erase, it can also erase itself. So, this is how we think about objects in Python. So, they have internal states. The state of this pen, this object, at this moment in time, is that it is just red, it is thick, and it's made of plastic. That is this kind of pen. Not every pen is red, thick, and plastic. It's true that most pens these days are made of plastic, but some of them might be made of, for example, feathers or quills or that sort of thing, and certainly they aren't all red and they aren't all thick, but our representation of a pen might have details about the kind of line it draws, its colour, what it's made of. So, a pen, as an object, for the system, would be something that has these attributes, and this current instance of a pen, this is an instance of a pen. 


This is associated with this instance, a pen. Every pen can write and every pen can be erased. This particular pen is red, thick, and plastic. So, the current internal state of this pen is thick, red, and plastic. We call these attributes simply details about the internal state of our object, and we have a set of things called methods which describe what my pen can do, and that's object orientated programming for you. Fundamentally, that's what it is. Everything describes a certain type of object that has internal states and can do certain things. Now, obviously, there are many, many other types of things in object orientated programming. I'm going to think of another kind of pen. This is my pen, this is my red pen. I could have a multicoloured pen. A multi-pen. What I'm thinking of in my head here are those pens where you click down one of the colours, you get to write in, for example, blue, and then, if you click down on another one, you get to write down in another colour. So, for example, you could write down in red. So, we would still have certain attributes, like before. We would still have the current colour, so, that's going to be red, to start off with, we'll see that this is a thin pen, so the thickness is equal to thin, and it's going to be made of plastic, and what can this pen do? This pen can write, it can be erased, and it can also change colour. Now, when we write with a pen and we erase a pen, we do very little in terms of changing its internal state. We aren't going to update the fact that it's a red, thick, plastic pen. That doesn't change. Yes, we might deplete the ink or something like that, but we're not going to think in that much detail, but the methods we have available to us in this multi-coloured pen will alter internal state settings. 


So, if I use my method, change colour, and I give in, say, a new colour of this pen, I might update my pen to be-, from being red to being blue. I might want to change colour again. I'll go from blue to pink. I might run-, change colour again, and it will go from being pink to being green. This is a method which will update the internal state of my object. I want to mention this, because, in Python, we have methods that do nothing in terms of altering the internal state and we have methods that will always alter the internal state, and then, we have methods that will only alter the internal (audio distorts 05.08) if you parse in a special argument that says, 'Alter the internal state of my object.' I want to mention this because, in Python, we have methods that do nothing in terms of altering the internal state, and we have methods that will always alter the internal state, and we have methods that will only alter the internal state if you parse in a special argument that says, 'Alter the internal state of my object.' The most important thing to think about, though, is, simply, that everything in Python that we work with is going to be an object. Now, with the exception of some things called literals. Think of literals as the atoms of the Python universe. Everything else is made of atoms. So, in this course, we are going to talk about inheritance hierarchies, but just quickly, to give you an example, I might have a general title object called a pen, and then, I want to add extra little bits of functionality onto it. Say, the ability to change colour. So, I'm going to make this a multi-pen and it's going to be associated with a pen, and it gets everything that pen can do, but it has some extra fireworks stuck onto it, like the ability to change colour. So, these are things called inheritance hierarchies.

About the Author
Thomas Holmes
Data Science Trainer at QA Ltd.

Delivering training and developing courseware for multiple aspects across Data Science curriculum, constantly updating and adapting to new trends and methods.

Covered Topics