Skip main navigation

New offer! Get 30% off your first 2 months of Unlimited Monthly. Start your subscription for just £35.99 £24.99. New subscribers only T&Cs apply

Find out more

Intro to Writing a Class in Python

Dr. Barb Ericson explains that in order to define a class in Python, you use the keyword class followed by the name of the class and then a colon.

This video explains how to write a class in Python. In order to define a class in Python, you use the keyword class followed by the name of the class and then a colon. This video walks you through how to create a class Car by showing you how to initialize object fields or attributes in the init method (init) and how to define what is printed using the str method (str).

This article is from the free online

The Power of Object-Oriented Programming

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now