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!