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
9860c95c
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
663a8e21
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
3f58a0eb
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
4f7e6b11
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d3548122
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8e0798c3
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0323983a
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
3a936b6d
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
1b9e81dc
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ad20a358
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8f8ab34f
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2c828865
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
acfa4956
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
eb9651c5
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.
Merging dictionaries là common trong config management.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6ef1aa12
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
de8426c2
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ec454092
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
59041c9b
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.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f2cd478a
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8b647efb
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5618d768
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.
Merging dictionaries là common trong config management.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
50a58e25
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
98958b92
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b6dbd902
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
4d98ffae
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
97614b73
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
22b69616
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Merging dictionaries là common trong config management.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d7e831d7
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
06c4c215
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.
Merging dictionaries là common trong config management.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f694c3f5
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
67a615ac
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4a5ae918
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a869b37f
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.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
7fa6957c
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
88b9eb92
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.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a1142603
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
44e95693
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
33248dfb
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.
Merging dictionaries là common trong config management.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b7e4f6f6
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
dd98af5e
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a78a9e9b
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
39e83d28
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
834318ea
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
28cebbc0
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.
Merging dictionaries là common trong config management.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e229dc09
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c8874e74
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
caf963c6
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
9de3dd17
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.
Merging dictionaries là common trong config management.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
e173fe7a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
5da2dc53
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
70e01c03
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c0837903
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
cd70962e
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c6dba10d
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
e58bc0c1
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
492dfb44
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
38c5fd16
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
d896c469
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
261f4e55
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
4b019ef8
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
6407c27c
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Merging dictionaries là common trong config management.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bb9761ff
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
255c6e80
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
480bf331
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
cf628399
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.
Merging dictionaries là common trong config management.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
98c3b74c
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
57155c20
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f118e6bd
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
07ce28a3
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.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b10c3ff6
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
9d2d0d74
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
eccbd328
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.
Merging dictionaries là common trong config management.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4f5a1332
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
fe6cf9ab
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
1497cd3e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
add843a3
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5bc05318
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
642523c8
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Merging dictionaries là common trong config management.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
738177e9
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
58af97a5
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
bc78769d
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
19ebee87
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
eceba745
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
aab71be4
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
89e3447f
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
dbe23970
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.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b9d9d5f4
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5c514d1e
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
280f444c
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.
Merging dictionaries là common trong config management.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
28a4e54c
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
296b0b9c
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
5d240a2b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
20371e26
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
3f9c8579
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
32c0185f
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Merging dictionaries là common trong config management.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
b2b26e35
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a193f779
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
b7616f79
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7625c467
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
34f1c41b
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]