Editor settings

General settings

Save settings

Learn to program with Python

Creating a simple class #

Classes serve as blueprints or templates for creating objects. To create a class in Python, use the keyword class followed by the class name.

For example, here's how to create a Car class:

class Car:
    pass
In Python, the naming convention for classes is to use the Pascal case, where the beginning of each word is a capital letter, with the exception of many built-in types, such as str, list.

Currently, the Car class is very basic. The pass keyword is used as a placeholder to indicate an empty class body.


Exercise #

  • Create a new Person class with an empty class body.

Tests #

  • Person should be a class.
Output will be displayed here