Get startedGet started for free

Public vs. private attributes

Excellent! Your coworker has decided to use object-oriented programming for the banking app they are working on. Now they need your help with implementing one of their classes, which is going to require both public and private attributes.

This exercise is part of the course

Programming Paradigm Concepts

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Define the Car class
class Car():
    def __init__(self, price):
        # price is a public attribute
        self.____ = price
Edit and Run Code