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
c7213cae
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f44f27a1
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
75b50edc
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
1f99f852
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
8f0a3493
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
bf9d1507
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ff47cf39
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6767ccb0
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9c6e6e22
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Làm phẳng list nested thành flat list.
Prime checking dùng trong many algorithms.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0c99d328
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f07f4e64
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
3a5f9c1d
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2801ec8e
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
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6f8d6b49
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
138929ea
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d6a93b3c
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2895c265
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7a9410a9
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7abba6a4
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
47daa42d
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
912bf870
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
2de671f5
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
21607fdb
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ce93dc22
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5f3bb354
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
406a9453
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Prime checking dùng trong many algorithms.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
18801ea5
# File I/O def read_file(path): with open(path) as f: return f.read()
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ce2b5da1
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
544de015
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5d84182b
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
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4a423fb7
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
2436501d
def count_chars(text): return {c: text.count(c) for c in set(text)}
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6b4e386c
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a5aa08ab
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1e44fd87
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
0e951f87
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9ab9f55d
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
954dff35
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
015fc7c7
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
dfe0bfdd
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
347e80db
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
4e05caa1
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f2452ed9
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Prime checking dùng trong many algorithms.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0425e444
# File I/O def read_file(path): with open(path) as f: return f.read()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
dc4b325d
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
9d1a5822
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
775758f0
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
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
2d90de22
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6ae7184c
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
be972e6b
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a1aa8335
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b7135240
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
dae93037
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6d6d5191
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a11dcb12
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5ef48171
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
3389eb55
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Prime checking dùng trong many algorithms.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
96c7a15e
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9d6bf2ca
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a20cb62c
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
356617f4
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
0d08be73
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
569292a6
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4a3a6749
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1754b6e0
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ec913eee
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
6c8a1356
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
b11e57b5
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
60933f10
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
2761d134
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
0589e8ae
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
40660dae
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
00462a95
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
046e2d50
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
dbdd0aae
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
7176763c
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4db77623
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a1c8cb6f
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
0f3a0491
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d761201b
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
d65d2909
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
dbfb5523
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ec140f46
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
49a7fa63
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
1736ee36
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
426eeb44
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ac00e8fe
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
734fc383
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9d4b0627
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
529a1179
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
71741da4
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ee244437
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0da6db02
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1d3b8000
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6080608e
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d33f1026
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d0f275f7
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
17b0dbbd
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a74b810e
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
5dc96140
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]