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 |
|---|---|---|---|---|---|---|---|---|
f89bdf3f | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fibonacci recursive. Chậm nhưng minh họa recursion. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
fff441b6 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Flatten thường dùng trước khi process lists. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
ad849070 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Flatten thường dùng trước khi process lists. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6086eeb4 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
0e2128e4 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
4810989b | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
6a9701e1 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
de6e3a24 | 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 | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
4cdb819a | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
9c147ada | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
c321087c | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
3c609f20 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
3a5fdf2c | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
ea73367c | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
79b60d41 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
7f1655a3 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
99b99081 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
9ba07873 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
b3b56710 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
0c50a535 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
02162731 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Flatten thường dùng trước khi process lists. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
18fa767c | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
fb917781 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
279af848 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
38365fc6 | 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 | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
4ed290f9 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
837c7221 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
c2b7ae49 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
4ee0f6a4 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
3c1cb901 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
20eb9c06 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
e4df51a5 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
1d1fdcd8 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
71261d97 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
f73527e1 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
2a9d3e3e | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
38a5b638 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6ddb1d34 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Base class cơ bản. **kwargs để flexible initialization. | Flatten thường dùng trước khi process lists. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
87b57189 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
098d80dd | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
49815f1a | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b5042a1d | 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 | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
ae0fd739 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
632d3de5 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
426f57c5 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
253254e5 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
42831708 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
528ed1c7 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
d8763601 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
6a96e6f1 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
a7371d14 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
8591c91b | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
a250ea27 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
991b3963 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6f58a68a | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Decorator log_calls ghi lại mỗi lần function được gọi. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
dcf9467d | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
f7addc4b | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
170efc13 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
ed9c2b3d | 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 | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
2ea30efd | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
1298eab4 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1c334a0 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
b5c73f93 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
6d8425ca | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
f15529bb | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
73e5e269 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
89ba84bf | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f11d0abb | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
698d02d2 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
2508742d | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
e73dfa16 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
0e14acd5 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Fetch data từ API endpoint. Trả về JSON. | Flatten thường dùng trước khi process lists. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
0080e192 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
0c2fd51b | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
30df7155 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
948577e0 | 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 | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
f6b2393d | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
4015c117 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
b106b2fe | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
097184b4 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
5be6b054 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
f7803791 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
506aede2 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
d223354c | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
6265fe64 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
b4c2ca6b | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
f472359f | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
4853b7ae | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
458d9acd | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Extract emails từ text dùng regex pattern. | Flatten thường dùng trước khi process lists. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
7ab26acf | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
0cbff845 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
62e19a2d | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
c776f6b0 | 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 | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
93cb0417 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
f52b6093 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
38d01236 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
1d5c231d | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
a4c69b38 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
83039232 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
e6f022ee | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Load JSON từ file. Trả về parsed object. | Flatten thường dùng trước khi process lists. | python | intermediate | [
"algorithm",
"math"
] | 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.