Classes
Classes in Computer Programming
Example in Python
class Car:
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
def display_car(self):
return f"{self.year} {self.make} {self.model}"
# Creating an instance of Car
my_car = Car("Toyota", "Corolla", "2015")
print(my_car.display_car())Example in C#
Last updated
Was this helpful?