MISSION 352

Object-Oriented Python

So far, we’ve focused on learning a system of programming known as Procedural Programming. In its simplest definition, procedural programming involves writing code in a number of sequential steps — and sometimes combining these steps into commands called functions.

In this mission, you're going to learn about a new system: object-oriented programming (OOP). Rather than being based around sequential steps, code in OOP is instead based on objects. (For now, you can think of objects as being closely related to variables; we’ll cover this topic in more depth in the actual lesson!)

When working with data, it's much more common to use a style that is closer to procedural programming style than OOP. But it's still important to understand how OOP works, because Python is an object-oriented language. 

This means almost everything in Python is actually an object. When you're working with Python, you are creating and manipulating objects. As you continue to learn to work with data in Python, you'll encounter objects everywhere:

  • NumPy and pandas — the two libraries essential to working with data in Python — both define a number of their own object types.
  • Matplotlib — which you use to create data visualizations — uses object types to define the charts you create.
  • Scikit-Learn — which you use to create machine learning models — uses object types to represent the models you train and make predictions with. 

So even though you may not use OOP techniques much in your data science work, you'll be using objects all the time, and it’s good to build an understanding of the basic concept. Understanding how objects work allows you to better understand what is happening behind the scenes as you work with data.

Objectives

  • Learn what object-oriented programming is and how it relates to the data science workflow.
  • Learn key concepts including classes, instances, attributes, and methods.
  • Create your own custom class.

Mission Outline

1. Introduction
2. Classes and Objects
3. Defining a Class
4. Instantiating a Class
5. Creating Methods
6. Understanding 'self'
7. Creating a Method That Accepts an Argument
8. Attributes and the 'Init' Method
9. Creating An Append Method
10. Creating and Updating an Attribute
11. Next Steps
12. Takeaways

python-for-data-science-intermediate

Course Info:

Intermediate

The median completion time for this course is 6 hours. View Details

This course is free and includes four missions and one guided project. It is the second course in the Data Analyst in Python path and Data Scientist in Python path.

START LEARNING FREE

Take a Look Inside