Dataset Viewer
Auto-converted to Parquet Duplicate
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
1101603d
# File I/O def read_file(path): with open(path) as f: return f.read()
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a611e5ed
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f57b3669
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
cf77c434
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
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f0ebd8ab
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
53c11d12
def count_chars(text): return {c: text.count(c) for c in set(text)}
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c920e9a6
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2941ee8b
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
2629a340
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ac32bc63
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
18777138
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
bf6fcce5
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d417251e
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
3815a238
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a9c640a0
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
a0b06605
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
309e4c1b
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e72c5acd
# File I/O def read_file(path): with open(path) as f: return f.read()
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
deb78a82
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
85555753
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
adcac8d9
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
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
40b06bb9
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6d6be3ea
def count_chars(text): return {c: text.count(c) for c in set(text)}
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6d31041b
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3cba0620
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8f096637
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
b2e32d15
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
435deb26
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
ef374f32
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
163bae2a
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
8bb46b67
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
8e88940e
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5ecff6f0
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Ghi nội dung vào file. Context manager tự động đóng file.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
fa73969f
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5974a33c
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
0f0028cd
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
5c3a71cb
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
1a58d4ed
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1074afb4
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6e9eced6
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
dbbdc53e
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3cba9f3a
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9b259454
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
45dff86f
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
e05f8848
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
5ac18379
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
3ab9ea20
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c5c2abb0
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
78e3529e
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5e2e3ca0
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
69d18825
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6192c5bb
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
8a68444a
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
495f89de
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ba3c8333
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
22f9fbdd
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
3bf0d4cd
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
81ce6c25
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
329a9b34
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ed3eba32
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
3739b180
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ca05d0f1
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
92afca71
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
adbd9283
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
07a6ea10
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
bbb53a7e
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
743bd973
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
55a92bad
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
070f162d
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
26b58a7b
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
22a06b08
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
415cfad0
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6e07dd64
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
53f22de6
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
cc022049
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
38146e68
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b46f0b7e
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e7025a5d
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
72c9e50c
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7510321d
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d4021637
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9f5e2392
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a4c31cfa
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c3e675a9
# 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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
d5231ebc
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.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
37c1cf1e
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
540e1815
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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
72fab904
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2f63f7d1
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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
afb64c33
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7076e2cf
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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
0e6f2986
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
b539c271
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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8c72888a
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f0471176
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
bd94dc42
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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
1cca9e2f
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
ec61b742
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c83ca648
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
94b72d67
# 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ự.
Sử dụng khi cần đọc toàn bộ file vào memory.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
72