id
stringlengths
8
8
code
stringclasses
17 values
explanation
stringclasses
17 values
context
stringclasses
17 values
language
stringclasses
1 value
difficulty
stringclasses
3 values
tags
listlengths
2
2
version
stringclasses
1 value
keywords
listlengths
3
3
eef17f7a
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
e98f7824
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
16531a87
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
c4575ee8
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
aab96afb
# File I/O def read_file(path): with open(path) as f: return f.read()
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
782ae4e0
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
819945b5
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
0dbae6c5
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6971abc6
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7653e1b0
def count_chars(text): return {c: text.count(c) for c in set(text)}
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
2c44dd71
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d63d37d0
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d5a0408c
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e7f096c0
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6c021af8
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
bbe8aba5
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
bd8778ca
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c4f01400
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b285db98
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
316440f4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9663fc30
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
OOP base class cho extensibility.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8ad64c80
# File I/O def read_file(path): with open(path) as f: return f.read()
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2416c7f9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
df1360d4
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2e31c6b5
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
b9be6572
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
26df8cf1
def count_chars(text): return {c: text.count(c) for c in set(text)}
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c8076f89
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2c5acd46
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7e59f4e2
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a257181f
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
7916de2f
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
90117a05
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
01085dfe
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
66d7704d
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d97b4def
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9b3cad43
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
65e10349
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Ghi nội dung vào file. Context manager tự động đóng file.
OOP base class cho extensibility.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5ae33c2f
# File I/O def read_file(path): with open(path) as f: return f.read()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
494752c9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
184ee37d
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
05cea5f2
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7ae906b0
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7e2d4abb
def count_chars(text): return {c: text.count(c) for c in set(text)}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ed9195db
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
38ffe99d
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
43540fb5
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
dae8b854
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
1394802e
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
8de0b3c8
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
926dfbfd
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
72bf971b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
fddf64b7
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
7dc4bae3
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8f1568b7
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
OOP base class cho extensibility.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a0ea5cb4
# File I/O def read_file(path): with open(path) as f: return f.read()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
624fa841
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
71586a68
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
e2c61370
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
16e7f5a6
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
dbdc6e19
def count_chars(text): return {c: text.count(c) for c in set(text)}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
b64b0f5a
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d86097b7
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ddaaf726
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7d146b44
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
377c556f
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6465d2bf
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
3f99b4ce
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c90d1de1
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
1130d751
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
1339b051
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a5d1e48e
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
OOP base class cho extensibility.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
00ab7ec1
# File I/O def read_file(path): with open(path) as f: return f.read()
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
15f0834d
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
bbe98853
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4c2dbca7
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
c201b624
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
39859b0e
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
0ec98c56
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
deee2db2
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
dca04e90
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
bda7acf6
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
172092b6
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
ce20bd7f
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c15d68b4
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f40ad731
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f185ca35
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
e7a1587d
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f91cecfc
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đảo ngược thứ tự các từ trong text.
OOP base class cho extensibility.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
cdc0c292
# File I/O def read_file(path): with open(path) as f: return f.read()
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a88c1034
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
8ef41d0a
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ba511113
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
ab24cd31
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
12550b41
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6dd4b170
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ca3f8d2f
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
90c874f9
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
2c04060f
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
bffa12b7
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đếm tần suất xuất hiện của mỗi ký tự.
OOP base class cho extensibility.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]