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 |
|---|---|---|---|---|---|---|---|---|
7e4fb118 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
d830f5b8 | 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. | String manipulation dùng .split() và slicing. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
406457be | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
ada62382 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
faee8186 | 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. | String manipulation dùng .split() và slicing. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
40033a91 | # 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. | String manipulation dùng .split() và slicing. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f2828004 | # 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. | String manipulation dùng .split() và slicing. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
a3c2a8e8 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
1ebacde5 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
d526739c | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
51213b38 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Extract emails từ text dùng regex pattern. | String manipulation dùng .split() và slicing. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
7ce345aa | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
16928d8c | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
83bae330 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
d255404b | 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. | String manipulation dùng .split() và slicing. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
a2e3961b | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
f3b867e9 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
5cb8835a | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
a2446759 | 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. | String manipulation dùng .split() và slicing. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
52e20f19 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
e022fbc1 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
eeff215d | 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. | String manipulation dùng .split() và slicing. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
f5a2e23c | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
b05f1bd4 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
a3930ee9 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
3472949e | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
49d1ccf6 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
913b0791 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Load JSON từ file. Trả về parsed object. | String manipulation dùng .split() và slicing. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
89a7588f | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
86adeb0f | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
4768bde2 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
72196044 | 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 | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
628ffe8e | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
8232f0d1 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
3d2a7989 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
420f6e46 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
6b8df0cd | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
cfea9383 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
4a284c95 | 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. | String manipulation dùng .split() và slicing. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
09fe39ff | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
c6d0b61a | # 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. | String manipulation dùng .split() và slicing. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
784d5f17 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
5b5d2425 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
9cd28027 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
342fb76e | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Save data thành JSON file. | String manipulation dùng .split() và slicing. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
d110349f | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
24f25557 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
e3d4066f | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
6ffa64a4 | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
a98b0e39 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
42034f06 | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
0eab8af6 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
cf8b20da | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
465e51fa | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
abc2c751 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
3f4cc988 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
5932ab88 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f778d12c | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
ce86af6a | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
426ed301 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
090ba655 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
d6262de5 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
56c6c0b8 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
63168f08 | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
1078b714 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
a0066ace | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
bf5e13a2 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Ghi nội dung vào file. Context manager tự động đóng file. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
cf66cc43 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
ab1460a2 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
723ed37f | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
afe6c18d | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
7af9fe0d | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
82ad9936 | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
935abee0 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
616cbeaa | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
f349017b | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
46094230 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
7910536d | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
66d9167d | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
0a783c00 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
b9c8da0f | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
4f0e689b | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
387f5c30 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
0321dfec | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
631bc49e | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
d872b622 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
a76c4633 | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
1ce2ea81 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a5d96739 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
8cab0783 | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ad0c373f | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
54547d6e | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
006f1b78 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
2e6ac0e9 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
7d751178 | # 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
ec5ddc47 | 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
104827e8 | # 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
620d3544 | 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. | Counter pattern rất hữu ích trong text processing. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
e47feb71 | # 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. | Counter pattern rất hữu ích trong text processing. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
7f78c2e7 | 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. | Counter pattern rất hữu ích trong text processing. | python | advanced | [
"grouping",
"dict"
] | 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.