ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Programming Paradigm Concepts

Ver curso

Ejercicio interactivo práctico

Pon en práctica la teoría con uno de nuestros ejercicios interactivos

Empieza el ejercicio