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
336a6a92
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Regex pattern matching cho text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
2a365485
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a8cf2e93
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f8e66dfd
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ea73422a
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.
Regex pattern matching cho text processing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
859bea80
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
18b74464
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e88382f2
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f7513a8d
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.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9f09d0bb
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
96916bfd
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
712f38bc
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.
Regex pattern matching cho text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b459ac07
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b1d7584a
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
94bb43d7
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
bf778250
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9518703c
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
dae9c0f8
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Regex pattern matching cho text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d798c6d8
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Regex pattern matching cho text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
26cdffec
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Regex pattern matching cho text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0e4bc673
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Regex pattern matching cho text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
6dfe0b43
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.
Regex pattern matching cho text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
205e5308
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Regex pattern matching cho text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
3152dab7
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
2b895809
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Regex pattern matching cho text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
27511426
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1a447e03
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Regex pattern matching cho text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
58c6e81d
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Regex pattern matching cho text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c3bf4fc6
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.
Regex pattern matching cho text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7a2cf20a
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Regex pattern matching cho text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
f527bdcb
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ce8d55d7
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Regex pattern matching cho text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
72f60c0e
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Regex pattern matching cho text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
671d6bfe
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Regex pattern matching cho text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
7227c3bf
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Regex pattern matching cho text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e128de0a
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
226d6186
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.
JSON là standard format cho data interchange.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
76745916
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4b4f4e6c
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.
JSON là standard format cho data interchange.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
44f9d44d
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7123526b
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
110f018e
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c48d9491
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
2493f7df
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
04244ae8
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9a9fbe7c
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.
JSON là standard format cho data interchange.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9cea961a
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5932d0b8
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2d0723bb
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
8e0d6880
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8c884a36
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
cbbf3f20
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.
JSON là standard format cho data interchange.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
c109a012
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a06269fd
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.
JSON là standard format cho data interchange.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
110437b4
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
0f4ce03a
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.
JSON là standard format cho data interchange.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d5ad008b
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
JSON là standard format cho data interchange.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0068d333
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ff9fcdb4
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3dd1314c
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ad4a0723
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c1f9f7f6
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
8fb8dd0b
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.
JSON là standard format cho data interchange.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f0ffe0d1
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
2dcf723d
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2c3d82c3
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
017816bb
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
d7f3d755
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
b521f37c
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.
JSON là standard format cho data interchange.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7c53f065
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
da9bb7b6
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.
JSON là standard format cho data interchange.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
6b52d7ea
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
45c987e0
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.
JSON là standard format cho data interchange.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
60a242a0
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
JSON là standard format cho data interchange.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d7a63255
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
5261a82c
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
343ce1fb
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
073ee567
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a78ba86f
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ee45c2c9
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.
JSON là standard format cho data interchange.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
423f827e
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
3efd67a0
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c36d9b26
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5b85acef
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
85bca045
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ba6c0570
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.
JSON là standard format cho data interchange.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
42eae035
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
aaace9dd
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.
JSON là standard format cho data interchange.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
e6b374b1
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
e288e542
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.
JSON là standard format cho data interchange.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d5878fa5
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
50796903
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
44131773
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
111433a6
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ba1e76bf
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7ac90f06
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2dbc35e0
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.
JSON là standard format cho data interchange.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6e684343
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5cc6426e
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
e7454eaa
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]