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
e6ec55ae
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
b380fe5b
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
5e231fc7
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
41c5a57f
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8f14727c
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
4e8af3c3
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6cff7764
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b1d0b7a0
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c096c493
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
02c9c8ff
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f4d29906
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1c9ed46c
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
API integration là core trong modern applications.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
efbf5ac5
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
635eb45e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f3f823f7
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ccb9970b
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
b4efaa4f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
c5002307
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c89186e2
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
e184a24a
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
02554db4
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f2a5f8a1
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2a0fb105
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b4a52e82
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5576b1f9
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b5f0fe71
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ad3ea34f
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f0889209
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4ae636a1
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
API integration là core trong modern applications.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
d178f528
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
API integration là core trong modern applications.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a4c34d3e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
1c9a14e1
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
API integration là core trong modern applications.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
621b8c02
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Save data thành JSON file.
API integration là core trong modern applications.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
14a257ea
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
fc0246c6
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
API integration là core trong modern applications.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
265998cb
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
API integration là core trong modern applications.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ebf6877c
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
fce2aa4d
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
API integration là core trong modern applications.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d966e715
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
API integration là core trong modern applications.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
a0eee978
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
fbf39ef2
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
API integration là core trong modern applications.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
06cf9220
# 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.
API integration là core trong modern applications.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
bb037b22
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
daf0176d
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
API integration là core trong modern applications.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
7ec76b6f
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
API integration là core trong modern applications.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
c45bfed6
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
API integration là core trong modern applications.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
29fa0855
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6b032bce
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.
Regex pattern matching cho text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
46c14830
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
67513553
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.
Regex pattern matching cho text processing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
c73422f6
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
2a0fa4de
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.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
43d6b91c
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
48977807
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.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d25e85d8
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
309f49f7
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3fd2ad91
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.
Regex pattern matching cho text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9ad220e2
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
23fb12cc
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a80c17c9
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5c548e55
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
acb13127
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
92f7985a
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.
Regex pattern matching cho text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
2d51c630
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
b40c5d69
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.
Regex pattern matching cho text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
53f27e86
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
e71a957f
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.
Regex pattern matching cho text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6d065747
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Regex pattern matching cho text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d3fa579b
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.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8141e895
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9ccaee98
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.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
53372b08
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
25579592
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
99c55890
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.
Regex pattern matching cho text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c457276d
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b40e0b95
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
97f0e020
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
38f24984
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
77d48815
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
66c70fb5
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.
Regex pattern matching cho text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
693c782a
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
3364c7b0
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.
Regex pattern matching cho text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
9d80a4a3
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f60abc17
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.
Regex pattern matching cho text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f2a957c3
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
050f196d
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.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
630a6c85
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
1a40f07e
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.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
25504c0d
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
4b19ecf5
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
ac2f00b2
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.
Regex pattern matching cho text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4ada4e5b
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
66742479
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
87760ab3
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
54651466
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8466b0b4
# 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.
Regex pattern matching cho text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
deb050b8
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.
Regex pattern matching cho text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7e33ab6a
# 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.
Regex pattern matching cho text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
e141723b
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.
Regex pattern matching cho text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
85d8e414
# 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.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]