ComeçarComece de graça

Identifying object-oriented programs in Python

You're going through the code at your company, looking for examples of object-oriented programming, and you find the following code snippets. Based on what you've seen so far, which of the following Python programs would be considered object-oriented?

Program A:

def buy_car(make, model, price):
    print("You've bought a ", make, model, "for $", price, "!")

Program B:

class Car():
    def __init__(self, make, model):
        self.make = make
        self.model = model

Este exercício faz parte do curso

Programming Paradigm Concepts

Ver curso

Exercício interativo prático

Transforme a teoria em ação com um de nossos exercícios interativos

Começar o exercício