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
1da666cf
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Ghi nội dung vào file. Context manager tự động đóng file.
Grouping là common operation trong data analysis.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bcc73432
# File I/O def read_file(path): with open(path) as f: return f.read()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
4fddb418
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0875aa24
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7d618f41
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
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
44754ad7
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
93835000
def count_chars(text): return {c: text.count(c) for c in set(text)}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
277c587c
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
78982b8c
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
2ba50a8c
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
239b3e03
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3e925ca3
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4c48f5e5
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
9c7ea4b1
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
94a7930b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
0fe4b67c
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
881e272a
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8b4ef1d7
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Grouping là common operation trong data analysis.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bd8b63e3
# File I/O def read_file(path): with open(path) as f: return f.read()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
e03de740
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
6a03ad58
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5381c358
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
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a678dfc5
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4ecf92ed
def count_chars(text): return {c: text.count(c) for c in set(text)}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
83b35e12
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8ab048ab
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9a7d5db5
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
dfbbb9ed
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2e8eadd4
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
115f2d26
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
6e8c1969
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a65b3057
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
9fa7e64a
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
556bccee
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f4b467c0
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Grouping là common operation trong data analysis.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
103ea8ab
# File I/O def read_file(path): with open(path) as f: return f.read()
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
64b5cd22
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
ccbedbbf
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
00d4a7df
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
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
862cf286
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0b9d549e
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
94c9c785
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
be3ebd8f
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.
Grouping là common operation trong data analysis.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
cd517454
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ae5d4e83
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
de48d5b8
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.
Grouping là common operation trong data analysis.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
33d67647
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8a29459d
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0ee72e9b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Grouping là common operation trong data analysis.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
7c1e3217
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
b6a301d3
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
626ca8ac
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.
Grouping là common operation trong data analysis.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a28f66d7
# 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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c2f72012
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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
bcc15921
# 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ự.
Grouping là common operation trong data analysis.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
594e8b54
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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4c992429
# 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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0156eff4
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ự.
Grouping là common operation trong data analysis.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a1145b5d
# 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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
b0ea78b0
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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b072e53c
# 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ự.
Grouping là common operation trong data analysis.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a795201b
# 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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
0f114b6f
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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
26d00372
# 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ự.
Grouping là common operation trong data analysis.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
07acd53f
# 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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
532fdf05
# 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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
93e2c2b3
# 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ự.
Grouping là common operation trong data analysis.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c87c52f7
# 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ự.
Grouping là common operation trong data analysis.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f937bab4
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ự.
Grouping là common operation trong data analysis.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8876dcbc
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2dde4807
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Grouping là common operation trong data analysis.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
beba426f
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
954fcf87
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.
Grouping là common operation trong data analysis.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8a8a92bf
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Grouping là common operation trong data analysis.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0f8d5454
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e4e25f0a
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
7946ae16
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7df38a3a
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
2ec3ddc8
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6c33aefb
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
02a26451
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
2404623b
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
aecd5324
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Grouping là common operation trong data analysis.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
fc2eb155
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
569e375c
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1b5607af
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bc9811fd
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
cfe5d254
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
2441821b
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7753ec23
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.
Grouping là common operation trong data analysis.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3bff7e6c
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0637a616
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
97a3ce5d
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ce2e25d4
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.
Grouping là common operation trong data analysis.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
da53bdf3
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
2004303b
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
729acc3b
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.
Grouping là common operation trong data analysis.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
e52201a8
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
7720758e
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
89c5778c
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Grouping là common operation trong data analysis.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]