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
f030d970
# 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
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
ef0d800f
# 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
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f0aa4451
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
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
060d7f74
# 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
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
9a0d2547
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
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
6c85257e
# 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
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2d91f937
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
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
edf4637d
# 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
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
42e56191
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
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8b9badfe
# 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
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
49872c0b
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
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
303d0d5d
# 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
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
de3d6490
# 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
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6de700aa
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
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
47bd7b94
# 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
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
50ddfc57
# 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
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9d93f2f7
# 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
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
77f7241f
# 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
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
60f9e4ab
# 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
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
fa5d337b
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
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e7dd6bca
# 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
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f0bb1744
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
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
5b689b90
# 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
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
c796bedf
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
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1e971d81
# 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
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6a0ef9be
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
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8259715e
# 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
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ee0fd4ef
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
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
29b17b9f
# 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
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5607f2c1
# 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
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
814183c3
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
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c97b583f
# 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
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c07a0aa3
# 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
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
1558a171
# 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
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
753584ed
# 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
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8f1e4dc8
# 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
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
209e60b9
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
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5e895ff9
# 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
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
b66cf075
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
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
62465963
# 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
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
dff81bd1
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
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
ec05ece1
# 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
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9ad901b7
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
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
49f02498
# 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
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
b8accf40
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
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
4f7758d9
# 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
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ef35481d
# 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
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5dde7618
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
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
e4154703
# 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
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d198363d
# 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
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
296f114e
# 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
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
da06dbb8
# 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
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6f222ef9
# 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
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e987edd6
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
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
935cadfc
# 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
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
696ffbe2
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
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
a5b05d60
# 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
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5f00532b
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
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4f927b31
# 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
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
f9271289
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
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f2cf1881
# 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
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ef8bbba5
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
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
3a3c00ed
# 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
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
072d9553
# 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
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c13187e5
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
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
70e67438
# 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
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
3ffdb692
# 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
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
deb554ce
# 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
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
53eabe27
# 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
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9351bab7
# 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
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
33b78674
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
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
c61a0d62
# 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
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
06392cdd
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
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
58e65601
# 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
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
bd0c9eae
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
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
894bad7a
# 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
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
98472dc0
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
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
46304a8d
# 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
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
5cd90b96
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
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7a0c10e5
# 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
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
52272419
# 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
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
04a08425
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
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f10f6dc7
# 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
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
85279066
# 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
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
be1849d7
# 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
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
85b133e0
# 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
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
ac286463
# 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
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e6dee44e
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
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5d733a97
# 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
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
03378083
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
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
97eda409
# 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
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8ba5a08f
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
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d71b87ae
# 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
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d0b96523
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
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
15577710
# 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
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
32b9de2d
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
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ff740582
# 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
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
91601a6c
# 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
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ba450b3b
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
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b426ff11
# 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
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]