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
a08364da
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
cbc411e3
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f1c04fea
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
35608add
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
be793804
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
3b4abc65
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
61f00f5c
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.
Grouping là common operation trong data analysis.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
82ac8110
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
b9ddf48c
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1cbed5dc
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
31f5bf1d
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.
Grouping là common operation trong data analysis.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
4522d6a4
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
762afb5a
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.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d9abcbfa
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
1cbbb961
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5ce031c0
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.
Grouping là common operation trong data analysis.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
90418f69
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
292f0090
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ba210260
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
8f8dde17
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0c843bb2
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
5d4ea7b6
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.
Grouping là common operation trong data analysis.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8b7a436a
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c927ffae
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d62d6d04
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
b4f09878
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.
Grouping là common operation trong data analysis.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
72464696
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Grouping là common operation trong data analysis.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
cad85e79
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.
Grouping là common operation trong data analysis.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ce802c24
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
5218848d
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
5befb199
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d03b60fa
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5582b436
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.
Grouping là common operation trong data analysis.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
7d35b6e2
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
daadf7ec
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
83e53964
# 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.
Grouping là common operation trong data analysis.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f766aa0b
# 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.
Grouping là common operation trong data analysis.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
fe7423b9
# 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.
Grouping là common operation trong data analysis.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
d05fb216
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
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
cc20481f
# 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
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f95869b6
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
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c969c217
# 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
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
34993acc
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
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
92e3c4cc
# 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
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a32bd767
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
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
afaa5204
# 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
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0f5db3b9
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
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
965d3ff1
# 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
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c32d4913
# 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
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fe2b1b86
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
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
8b69bf5b
# 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
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
2c832111
# 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
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ab577793
# 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
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
071d6f99
# 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
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
837c34f3
# 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
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
d9422946
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
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e18d122e
# 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
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
136b69e5
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
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
1d4b6134
# 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
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f7a3ee2f
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
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
c10a07be
# 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
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
fc044fa4
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
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6fa1dc52
# 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
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f68960e7
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
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d220d587
# 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
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
67a59396
# 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
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9ba433ce
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
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d1d562aa
# 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
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8f69d769
# 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
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a18a3155
# 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
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
deaf0c68
# 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
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
307f3160
# 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
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
3a9bf92f
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
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
522e39fb
# 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
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
de4258a9
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
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
3f495c77
# 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
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
89437e82
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
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
49d2e27b
# 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
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
67dca450
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
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6484e6a0
# 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
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2724be9b
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
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
aced307b
# 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
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ace4d3f5
# 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
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
56da3b78
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
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
beb9f37d
# 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
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
0c981514
# 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
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
35f6a2ce
# 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
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
0fca0c4d
# 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
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c78ea55b
# 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
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4e424e19
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
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bf960e48
# 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
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
7a9d110c
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
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
378db55f
# 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
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
6261b3cb
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
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8c487900
# 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
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
f4fda717
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
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
20d2f667
# 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
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
269ef62c
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
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f77575b6
# 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
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
6d89b141
# 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
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]