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
cc963681
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7440356a
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f2812749
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0adab7ca
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
c854e86c
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
9ecdcf1e
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ac524f24
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
268ef6d5
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
18df1ef5
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
faeb6a7a
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
fda40202
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
a9a15fc5
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
97d67dd4
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
82b64cc2
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
e7290214
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f1ac2517
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
77336862
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
85ee0ec7
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
32fe9b52
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
84992978
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c7c8f594
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
6ea64e0d
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
9115e36a
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
b7a0cb18
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
312213a3
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
2ff2e368
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
929746eb
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
19da9454
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0a760e9e
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
60829e06
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0f1f805e
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f3594173
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
8d24b783
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8f5eab6d
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
be603f60
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
60a8b34e
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
4b6af35d
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
1d3a5eb8
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
78698510
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
790c0225
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
1e7d8e34
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9e2b13aa
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
440283dc
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
8798a018
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ac97127a
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
7ca60630
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
39d50138
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0b979baa
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d24e92b9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
ee6b32cd
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8f821f56
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f1a717a3
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
1fab3343
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
355b2c43
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8272d0d2
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8adb4a3b
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e3d46991
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
686e1508
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6a87813f
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
0e8fe28b
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
bc9c9195
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
93b7634a
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
89253c46
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9635bde9
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5983ded1
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c12f8517
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
e44d06a9
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
6ef2ac8b
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
0961c6ea
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a7aa2827
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
1fed59de
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
cda96d41
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
3ae309dc
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e446bdd7
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c16c5b4b
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
cc80b7ad
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
a4074ce0
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
6e67fc91
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
23aeb2c8
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f997dabd
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e70a5566
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
f929b1fc
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f98a0127
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
3d26e710
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
1dd0a26e
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
42c35bd8
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6a1329db
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
42c482c4
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
37c401be
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
702f3300
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
b2a75c2d
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ae1360b6
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
248d1900
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
04147ed4
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
39652c5f
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
e9e9e359
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
78809bfd
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ab12f355
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
be065ceb
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c3a3d627
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]