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
7a6afa55
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.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
77d5e1f9
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
63c74c40
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fcc2a43e
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.
Thường dùng trong data preprocessing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9af7e699
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
a96395e2
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9a346d4e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Thường dùng trong data preprocessing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
739d6c33
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
aecc4d92
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e5071f71
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.
Thường dùng trong data preprocessing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d12dabf3
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
39d9a079
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
513d020e
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
67fd1d4a
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.
Thường dùng trong data preprocessing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
00a0e024
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
257752c8
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
de9a29d5
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
5089c604
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
5e03c763
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
28c8f9ae
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c13a7750
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
803d279f
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
7cfc4bc3
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
31aed995
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
70e6a1a7
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f975a145
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
5d35ac5a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Thường dùng trong data preprocessing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0a34281f
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d50c8f09
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.
Thường dùng trong data preprocessing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
49bc656e
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
a3c0063d
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.
Thường dùng trong data preprocessing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
08003957
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
1776d556
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
7868a492
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
12490d07
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.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
41333d0f
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
b7ebc63c
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
560f5d91
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.
Thường dùng trong data preprocessing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
82074d6b
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
69c90176
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
6348e921
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
848114f0
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
028c9bbd
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4b0bd06e
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.
Thường dùng trong data preprocessing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
31aa18c6
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a8c00f2a
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Thường dùng trong data preprocessing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0a9fe182
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
217a6cb6
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d30ecef2
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d2ae82da
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a7f00ab8
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
4428f33e
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.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f9319af9
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8fd91fea
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5948e22b
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.
Thường dùng trong data preprocessing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9d05f3e1
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
f11c15e6
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
e3a2ad27
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Thường dùng trong data preprocessing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
521bbe8e
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
776b5210
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
5505b444
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.
Thường dùng trong data preprocessing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
b489d618
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
5cc9a166
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
2cae4608
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
48c29eb3
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.
Thường dùng trong data preprocessing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
b53ea264
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4531e979
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.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
3dc58590
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
457c8277
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7442b6dd
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
78977fe7
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
32424c40
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9a2736d5
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
4727f14d
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
253a0f9a
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f340a676
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
1666050b
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
5f7661cd
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
b89fbd59
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
5abe6e61
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
49519bf2
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
dae80e98
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.
Thường dùng trong data preprocessing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
604ca32a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9d7962ec
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
3f8ea438
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c03aabcd
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.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
724294ab
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5189668f
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
19620a15
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.
Thường dùng trong data preprocessing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
31cb7cb0
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
41e4d411
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c4cb80a1
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b23b0e86
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
4b62dc59
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1d52636c
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
68cf0874
# 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.
Thường dùng trong data preprocessing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ac916662
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.
Thường dùng trong data preprocessing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
65cf1462
# 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.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5128dd10
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.
Thường dùng trong data preprocessing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
41b20363
# 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.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]