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
bf778ebe
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
13083a5c
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7b44ccb5
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6492bdf9
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
41a0cf3e
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
7a2127f6
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
20ef0de2
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
2db00954
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c1fe52ea
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
57f9efc3
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
56c2b31c
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
21b0a989
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
6812cf09
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7b4f2fc3
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
29452e1d
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7b68ebc9
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
26d83ddc
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
bc52345e
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7b57e299
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
77eb40a6
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
1049927d
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
3fa4f347
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8d462251
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
fa123539
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
323d96f1
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
2d153177
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
cc6fe9a8
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
f349ee72
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ba5aa438
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f4fe848e
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
d8cdd105
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
890b5006
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4c1ee515
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c15eb5b7
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
abfe57bb
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b4647bab
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
4a80fb9d
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
0de9d215
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
03b372e0
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
fdf687ae
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
e21f41e6
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
af2bc41d
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
cda9e79a
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
21a0d312
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6ea8a799
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
94a7d4a7
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
b6c238b0
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
9e427032
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
5393f870
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
90aa687b
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
528d3c53
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
09e390f4
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8f56e6ce
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c861de4c
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
60bbd994
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
ead896b6
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b85f85a4
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
3f2b3ae9
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
854deb03
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
2b33d547
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
2c194b56
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d97ab6be
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2de47f03
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d37761cd
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
99bd0d42
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f3238f6e
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
68525a46
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
4e65d5bc
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
94dc6560
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
e5f193b4
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5a5eb358
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
956391eb
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
713a048e
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e93d27da
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
4e9d5e6e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
7329a741
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
d5f702d0
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
13d9a4b5
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
41ae9966
# 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ự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
33a98d8c
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ự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
885696fe
# 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ự.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
d039d298
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ự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3933187f
# 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ự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
05fd332c
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ự.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e261c973
# 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ự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
cd37cb85
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ự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
e052be7e
# 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ự.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ffb60134
# 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ự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9af51d20
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ự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
5faf0326
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
cdd518f2
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
29f0e1ba
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
40a20003
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
317da9d4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a4fa1595
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đếm tần suất xuất hiện của mỗi ký tự.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
1edb4849
# File I/O def read_file(path): with open(path) as f: return f.read()
Làm phẳng list nested thành flat list.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a5c96c8f
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
145c9a09
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Làm phẳng list nested thành flat list.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
90fb9bae
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
Làm phẳng list nested thành flat list.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6376a806
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]