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
1bd42af4
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
0477cc17
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
fe5ececb
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ff42b55d
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
297627ef
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6a53f461
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7f198461
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e2ca8fd9
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
1b0f4a84
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
6219edac
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
28dc097e
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
28918a40
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a59c7534
# 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.
Try-except pattern cho error handling.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
47feac86
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.
Try-except pattern cho error handling.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
74567d14
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
57fb2779
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.
Try-except pattern cho error handling.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
72c9594d
# 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.
Try-except pattern cho error handling.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
871d71a4
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.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f5e438ac
# 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.
Try-except pattern cho error handling.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
00007d82
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.
Try-except pattern cho error handling.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
e15ad428
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f0565803
# 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.
Try-except pattern cho error handling.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
1b471e57
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.
Try-except pattern cho error handling.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
5f300941
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
a5887650
# 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.
Try-except pattern cho error handling.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
77b04a48
# 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.
Try-except pattern cho error handling.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
e3df1041
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
27eb6324
# 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.
Try-except pattern cho error handling.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1995488b
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.
Try-except pattern cho error handling.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
42a7432d
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
e8bb269f
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.
Try-except pattern cho error handling.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
b3e2e97e
# 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.
Try-except pattern cho error handling.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
886c7c44
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.
Try-except pattern cho error handling.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
e1814592
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Try-except pattern cho error handling.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
961468e2
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.
Try-except pattern cho error handling.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e27e248d
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f6a95864
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.
Try-except pattern cho error handling.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f42a7411
# 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.
Try-except pattern cho error handling.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e5d8d0ac
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
eb3f4ff6
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.
Try-except pattern cho error handling.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
04b05dc5
# 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.
Try-except pattern cho error handling.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
02bb2519
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2c3c6256
# 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.
Try-except pattern cho error handling.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
26a4a65b
# 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.
Try-except pattern cho error handling.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
d776e422
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ae5e8dac
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.
Try-except pattern cho error handling.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
79b0f106
# 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.
Try-except pattern cho error handling.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
23874151
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.
Try-except pattern cho error handling.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
38243c76
# 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.
Try-except pattern cho error handling.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f4631511
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.
Try-except pattern cho error handling.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
35be278d
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Try-except pattern cho error handling.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
33539bfd
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.
Try-except pattern cho error handling.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
88ffb4b7
# 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.
Try-except pattern cho error handling.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
144cc8e5
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.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
c338e09f
# 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.
Try-except pattern cho error handling.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e1a951ea
# 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.
Try-except pattern cho error handling.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
d0c9fc31
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.
Try-except pattern cho error handling.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7d7bd218
# 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.
Try-except pattern cho error handling.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b0652ffc
# 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.
Try-except pattern cho error handling.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a88c726a
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
3f6327e8
# 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.
Try-except pattern cho error handling.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
20061830
# 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.
Try-except pattern cho error handling.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
732ad4e9
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.
Try-except pattern cho error handling.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a3c441e1
# 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.
Try-except pattern cho error handling.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
74a5cfa0
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.
Try-except pattern cho error handling.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0764a48e
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
72fb00b9
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.
Try-except pattern cho error handling.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
9b881796
# 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.
Try-except pattern cho error handling.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
c61c18ed
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.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
39a35a21
# 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.
Try-except pattern cho error handling.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a2cc25f1
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.
Try-except pattern cho error handling.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
19b904cc
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d0221ec9
# 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.
Try-except pattern cho error handling.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6a330b8c
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.
Try-except pattern cho error handling.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6575e17a
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
579d181c
# 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.
Try-except pattern cho error handling.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
56a35a8e
# 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.
Try-except pattern cho error handling.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d84fadb5
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
31ac7ffe
# 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.
Try-except pattern cho error handling.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
91a3629b
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.
Try-except pattern cho error handling.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
28b5f2b5
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2bc5789f
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Try-except pattern cho error handling.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0817ca73
# 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.
Try-except pattern cho error handling.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
efdfceb1
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.
Try-except pattern cho error handling.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7d4b1f5c
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Try-except pattern cho error handling.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
29d142e3
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Try-except pattern cho error handling.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d2e45b72
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2a8403fa
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.
Try-except pattern cho error handling.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
2fa182a7
# 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.
Try-except pattern cho error handling.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
664100ba
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9042e62a
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.
Try-except pattern cho error handling.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
1e5a3627
# 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.
Try-except pattern cho error handling.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
80e65912
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
abce556a
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Try-except pattern cho error handling.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
7d2cb6e6
# 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.
Try-except pattern cho error handling.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
1b24f73b
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
44f2b51f
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.
Try-except pattern cho error handling.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d66c0e1b
# 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ự.
Try-except pattern cho error handling.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ec885a78
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ự.
Try-except pattern cho error handling.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d6b3ac91
# 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ự.
Try-except pattern cho error handling.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]