7554425D-0054-440D-B95E-D2ABC13D62CD Created with sketchtool.
{body}
Your Saved Info Packages

View your saved Course or Program Packages containing pricing and detailed curriculum.

Speak with a Learning Advisor.

Have any questions? We'll call you.

Fill out the form below and a Learning Advisor will reach out at a time convenient for you.

Please pick a valid date and time between 9 AM and 8 PM eastern (Monday to Friday)

By clicking "Book a call," you accept our Terms and will also receive exclusive offers and updates about new courses, workshops and events.

Python Tutorial

Python Class

Ready to start your career in Data? Find out more about BrainStation's Python Course

Python supports Object Oriented Programming (OOP) like many other popular programming languages. OOP revolves around the idea of classes and objects.

A Class in Python is a blueprint from which objects can be constructed. Imagine class in OOP as a sketch by an architect for new building construction. Civil Engineers and construction workers then bring this sketch to life by building a real world object i.e. the building in this case.

Naming convention for a Python class is PascalCase. A class can be simply defined as follow in Python:

```
class NewPythonClass:
	'''A docstring like this explains what the class does'''
	pass
```

In the example above, a class in Python can be defined using the class keyword followed by the name of the class. We defined a docstring within the class to explain what the class does and why it is implemented. It helps in providing a detailed explanation about a class.

A class in Python has attributes or properties and methods that act on those attributes. There are also attributes and methods that are pre-built into every Python class and they start with two underscores and end with two underscores __. For example, __init__ is a special method that is used to create new objects from the Python class. __str__ is a special method that is used to provide a string representation of the class when objects are created from it.

Objects are created from a class by calling the constructor function which is __init__ by using the name of the class followed by parentheses (). Any attributes that are needed to create objects from that class will be passed within those parentheses.

Set Password

You already have an account with BrainStation, but you still need to set up a password.