Skip to main content

Class Basics

What is Object-Oriented Programming (OOP)?โ€‹

Object-Oriented Programming is a programming paradigm that groups data and functions together into a single unit (object).

# Procedural Programming
user_name = "John Doe"
user_age = 25
user_email = "john@example.com"

def print_user_info(name, age, email):
print(f"{name}, {age} years old, {email}")

print_user_info(user_name, user_age, user_email)

# Object-Oriented Programming
class User:
def __init__(self, name, age, email):
self.name = name
self.age = age
self.email = email

def print_info(self):
print(f"{self.name}, {self.age} years old, {self.email}")

user = User("John Doe", 25, "john@example.com")
user.print_info()

(Rest of the content is the same as the original Korean file, with minor language adjustments)

Next Stepsโ€‹

You've mastered the basics of classes!

Key Points:
โœ… Class and instance concepts
โœ… Initialization with __init__
โœ… Instance methods and self
โœ… Class variables vs instance variables
โœ… @classmethod and @staticmethod
โœ… Encapsulation and property

Next Step: Learn inheritance, polymorphism, and magic methods in Advanced OOP!