A basic class consists only of the class keyword, the name of the class, and the class from which the new class inherits in parentheses. (We’ll get to inheritance soon.) For now, our classes will inherit from the object class, like so:

class NewClass(object): # Class magic here

This gives them the powers and abilities of a Python object. By convention, user-defined Python class names start with a capital letter.



Create a class called Animal in the editor. For now, in the body of your class, use the pass keyword. (pass doesn’t do anything, but it’s useful as a placeholder in areas of your code where Python expects an expression.)

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?