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 |
|---|---|---|---|---|---|---|---|---|
f8189861 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Save data thành JSON file. | Try-except pattern cho error handling. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
30382147 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
dd800ce6 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
22d4d284 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
09c3248c | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
52990fb1 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
5f8bcd75 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
036cf9a9 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
ebf5d326 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
513c8e39 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
db6f61ed | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
a46c0af4 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
89c1e37e | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1e7a672 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
4809e214 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
2cd2f7b0 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
9a4976c6 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
d938dcc1 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
f4ab61b3 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
e8beda08 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
3a68c24e | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
a77284c3 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
0fa91f68 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Ghi nội dung vào file. Context manager tự động đóng file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
30b587d5 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
90301ebb | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
424d80c2 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
ec9c5e13 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
3e6e2388 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
4e88cb39 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
50aef900 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
fcd6a17d | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
1083dee9 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
e6d52d24 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
90e6212f | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
fbba12bf | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
beef3c45 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
e580a0be | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
4e95316b | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
5e4f63b3 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
69c833aa | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
afeab3c6 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f1c68b36 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
c564a87a | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
fbccfc05 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
1d28b3c7 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
77595298 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ec2c7493 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
2706a3e8 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
e8a881bb | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
4fe436f8 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
bf17ecc6 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
3f275762 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
e507f084 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
67f7c3f8 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
d3e126d4 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
14c41580 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
c2368546 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
3cff37c0 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
d933355e | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
661bf371 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
a921aee0 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
2d56587e | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
370ef5ac | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
3c012b36 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
6808786e | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
c8293fa5 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
3c5814bf | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
dc4d3981 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
8a2bb514 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
8c1c0bb8 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
17fb82a2 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Đảo ngược thứ tự các từ trong text. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
6e29c2f0 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
bcb5ef40 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
43412862 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Đảo ngược thứ tự các từ trong text. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
7f2d6432 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Đảo ngược thứ tự các từ trong text. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
88ea265a | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
53443ba3 | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
76f2fb26 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
29c64dc0 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
256ae13e | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ccd8237f | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
56029636 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
11b0889d | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Đảo ngược thứ tự các từ trong text. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
624e6d5f | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
92b89487 | # 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
0620c26e | 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. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
c02ceb4a | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
348e09d3 | 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
b10cb64e | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
69b10c7b | 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
b1231a07 | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
7db68220 | 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f584b141 | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
143f5387 | 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
cde4b45f | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
e3bd9701 | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
54bbdb0b | 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
200a184f | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
a8f10d36 | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
25d51a8a | # 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ự. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.