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
f86f14be
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8f4e8c94
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
37ce0905
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
997c4b84
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9c30c135
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
8323efea
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
565e3090
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
bd5404c2
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d889fe3f
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
4d15fd82
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
b4d5d6db
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8bcd1746
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ed52bb38
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c228227d
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f4335760
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3d5cb64e
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
fd1bb198
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
b5f531de
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a9d05f28
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
e764e3bc
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
753e84f9
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fa8dd473
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
33d759c1
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
f3771f3f
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
cf69a121
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
dcbcee8e
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
50f92e59
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
547e185f
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
36a3dd22
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
7781d903
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d72b3b90
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5505a6c1
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
873dfb68
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
bd8a1972
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
9ca0538b
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
cf4f8e2c
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
986fdae7
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5734270e
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
8f1b3989
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
17e29cd1
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
6c0015cb
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f3c4cdc2
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
9352609b
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
502e79b7
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
86fc2f4a
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
f8522baa
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
86b8ebb5
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
4d73936d
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5f3cef2d
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
12458369
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9dc7ce80
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
60dff60e
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
e8691f00
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1b2faa04
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ffd03d60
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9ac04e0a
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
80aae3fb
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e1dd43e8
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
1201f1d0
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
af9c5367
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c6e69c25
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a7757ddb
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
09036de9
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
cd528d8c
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
String manipulation dùng .split() và slicing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
1788301c
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
fce2866b
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4d9d9dd5
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
addfe8f7
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
978879e3
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a8942046
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8373955c
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
31ce5b52
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
f6dde0f2
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f2431f75
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
6a98cc51
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
efe77d15
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
String manipulation dùng .split() và slicing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
180e4f0a
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
e48d8c58
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
41005ef5
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d3f09ff3
# 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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
101fbed7
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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
3a08be08
# 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ự.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ff5f6196
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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f7fa4b97
# 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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
89c54761
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ự.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
7945552f
# 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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
54621eb6
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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
eece685d
# 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ự.
String manipulation dùng .split() và slicing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
121674e2
# 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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
f427ad82
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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7da8e6ef
# 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ự.
String manipulation dùng .split() và slicing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5b8110aa
# 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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c0a07ac4
# 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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
54dd1791
# 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ự.
String manipulation dùng .split() và slicing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
411ee922
# 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ự.
String manipulation dùng .split() và slicing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
2f42c250
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ự.
String manipulation dùng .split() và slicing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8fa90224
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
06ec2872
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
String manipulation dùng .split() và slicing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
e8a9368b
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f5cf46be
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]