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
7f1ebc74
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
21428f2a
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
fa683169
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d9de03b9
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
445bea53
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
0bb61bdf
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e67b3133
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0f65982c
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b9341c83
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
db01cc7c
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8203d2ee
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đảo ngược thứ tự các từ trong text.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d3447b6d
# File I/O def read_file(path): with open(path) as f: return f.read()
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6d56681e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
411ff4c0
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
d0b415c1
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
99336a02
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
1bb2c579
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
02c60dbd
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
23c05673
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9541c5c6
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
56fa11a6
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
df20e3a9
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
961e9f00
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8e1e2385
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b0968ec3
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
7ae67614
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9094b567
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
194adea8
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đếm tần suất xuất hiện của mỗi ký tự.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6d781ac1
# File I/O def read_file(path): with open(path) as f: return f.read()
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
01904a72
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
467c24ef
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
be634d78
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
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8a3b8ecd
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
532591d1
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
706f890b
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a262c8af
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d15b3801
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7db68cac
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3684b3fe
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
67ef17ab
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d850ff9c
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
086a058e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d2dd1b4c
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5a9c2641
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
47725861
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Làm phẳng list nested thành flat list.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6b7850ab
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
8a092506
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
291a6956
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
9a522782
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
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
9c06cca7
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
837bf124
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
783d53cf
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
566b2cc9
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
64378b55
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
4fddfb61
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
d595023e
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
615fe1a5
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5e420ceb
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a95945d8
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
9c112d6b
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6949e6f6
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
fadbe07e
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
68525480
# File I/O def read_file(path): with open(path) as f: return f.read()
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
b54c8675
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
03e38bcb
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
9ddf40b7
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
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
70707ee1
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
3a9b9f24
def count_chars(text): return {c: text.count(c) for c in set(text)}
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
b1553e53
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
55338394
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
0e2d1d92
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
6f481797
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
332c35f4
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a4464e2a
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b9fd0bdd
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f8982ff6
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
96501e22
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
99f5cee9
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
74be5711
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
edf5b375
# File I/O def read_file(path): with open(path) as f: return f.read()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2255bed4
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
4309b14b
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
27bb644d
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
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d9f5a6a9
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
23e85a71
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
75bd917e
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f013ddd8
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
fc29d1af
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
1cae5e43
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fc00e56a
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7bc17ff5
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
4afe95c7
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
cb088d9f
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
95330246
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
46a7b60d
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
071a89b7
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
934844bb
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
7c4259a3
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
23da04ba
# 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.
Recursion là important concept nhưng cần cẩn thận performance.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
bada6b74
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.
Recursion là important concept nhưng cần cẩn thận performance.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]