MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Programming Paradigm Concepts

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Define the Car class
class Car():
    def __init__(self, price):
        # price is a public attribute
        self.____ = price
Edit dan Jalankan Kode