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
1763394d
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6b818386
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
1b8cdf42
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9361353d
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b27280ed
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
63642498
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
17689f11
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Try-except pattern cho error handling.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
ac64f8ef
# File I/O def read_file(path): with open(path) as f: return f.read()
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6242e75f
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
27c30b91
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
a8a6531a
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
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8b09daf2
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9de92e66
def count_chars(text): return {c: text.count(c) for c in set(text)}
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e159252a
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0cabee0c
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a1e8b808
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
0e57d0db
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c70cc16f
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
40ccc0f1
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
4bf05b8c
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9e599921
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b3f3c269
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c858dbfa
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f832d86c
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Try-except pattern cho error handling.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7d5f13cf
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
c53ea20b
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
651a3605
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
b3b55f97
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
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3144570b
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
f483afef
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
152d02ec
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3a56d978
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
0abc959a
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
21664e50
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
95a1966b
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
461c39cc
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
53634002
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0ec97475
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
e5774e9f
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
3afd29c1
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
261d7e45
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Try-except pattern cho error handling.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
b1413d85
# File I/O def read_file(path): with open(path) as f: return f.read()
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a2b4d463
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
92732ad1
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
bca7850d
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
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f3b08958
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
2bf19c5b
def count_chars(text): return {c: text.count(c) for c in set(text)}
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
aa8071bc
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
6c2e3851
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
416e6bd2
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
168dc16c
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
03316802
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
25de041d
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
55199398
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
5e3d2d10
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a2198c95
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
3ee160d8
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
496ff059
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Decorator log_calls ghi lại mỗi lần function được gọi.
Try-except pattern cho error handling.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
da44b751
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6cbb556e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
eff75611
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
c167780d
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
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d4994353
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
73353cd7
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
cff3a4e6
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
4b061608
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ba4e92cd
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
98615844
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2448e24d
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
855f6fb9
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e0157d83
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
203638e7
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
3adfa8d5
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8f9cbbb3
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f35e9b5a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Try-except pattern cho error handling.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
10c6c873
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
b7b0e1ad
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
669177ca
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
50c26b76
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
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a9337b01
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
1d6a78f1
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
429c5eb7
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
657b13b3
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.
Try-except pattern cho error handling.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
3748aa4f
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c4e47aea
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
80463cf8
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.
Try-except pattern cho error handling.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c5168072
# 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.
Try-except pattern cho error handling.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
911301ca
# 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.
Try-except pattern cho error handling.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
1a0a7501
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
21a5d020
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
ff40d781
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
3e0da509
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Try-except pattern cho error handling.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a1884ed6
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d286c601
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
9150ade1
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
91f0a00c
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.
Try-except pattern cho error handling.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
0f1f1705
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
bfa79236
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
95f07be1
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Try-except pattern cho error handling.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
369d8d12
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.
Try-except pattern cho error handling.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]