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 |
|---|---|---|---|---|---|---|---|---|
3eeafb99 | 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. | API integration là core trong modern applications. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
b21e2917 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
e1e8cac9 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
2f8ae06a | # 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. | API integration là core trong modern applications. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b596fc58 | 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. | API integration là core trong modern applications. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
6353fe27 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
18717a7d | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
9fe0053f | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
535968c1 | 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. | API integration là core trong modern applications. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
b4d71632 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
9466a7b9 | # 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. | API integration là core trong modern applications. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
daf9523c | 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. | API integration là core trong modern applications. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ae972a5d | # 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. | API integration là core trong modern applications. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
5d8556a1 | # 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. | API integration là core trong modern applications. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
04fc0fcd | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
564f3596 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
0c2e7ccb | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
cb9ad8fa | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Gộp nhiều dictionaries thành một. | API integration là core trong modern applications. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
a988eb8a | # 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. | API integration là core trong modern applications. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
37c47fdf | 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. | API integration là core trong modern applications. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
bbfc2898 | # 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. | API integration là core trong modern applications. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
8d2c8500 | 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. | API integration là core trong modern applications. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
1e26c770 | # 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. | API integration là core trong modern applications. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
db097b8b | 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. | API integration là core trong modern applications. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
04643166 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
df829d83 | 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. | API integration là core trong modern applications. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
7d47d31e | # 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. | API integration là core trong modern applications. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
f43b4616 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
367fb665 | 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. | API integration là core trong modern applications. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
596620cd | # 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. | API integration là core trong modern applications. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
83538737 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
f9f35ab2 | # 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. | API integration là core trong modern applications. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
1f95b01e | # 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. | API integration là core trong modern applications. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
157ae26b | # 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. | API integration là core trong modern applications. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
fb5f6ad0 | 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. | API integration là core trong modern applications. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
f5726f4c | # 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. | API integration là core trong modern applications. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
f16cbd5c | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fibonacci recursive. Chậm nhưng minh họa recursion. | API integration là core trong modern applications. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
99c0384b | # 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. | API integration là core trong modern applications. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
6bb067c2 | 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. | API integration là core trong modern applications. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
1655278e | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fibonacci recursive. Chậm nhưng minh họa recursion. | API integration là core trong modern applications. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
7bc299d9 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fibonacci recursive. Chậm nhưng minh họa recursion. | API integration là core trong modern applications. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
001777cb | # 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. | API integration là core trong modern applications. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
3cccc6df | 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. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
4a7df07d | # 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. | API integration là core trong modern applications. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
645a1a43 | # 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. | API integration là core trong modern applications. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
f2d6e19e | 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. | API integration là core trong modern applications. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
2223c7e2 | # 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. | API integration là core trong modern applications. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
50e64998 | # 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. | API integration là core trong modern applications. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
762f8a1f | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fibonacci recursive. Chậm nhưng minh họa recursion. | API integration là core trong modern applications. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
224616cd | # 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. | API integration là core trong modern applications. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
b7585505 | # 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. | API integration là core trong modern applications. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
5e118180 | 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. | API integration là core trong modern applications. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ee84726 | # 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. | API integration là core trong modern applications. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
607ead83 | 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. | API integration là core trong modern applications. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
5dac6efc | # 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. | API integration là core trong modern applications. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
e61c0de4 | 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. | API integration là core trong modern applications. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
324f085b | # 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. | API integration là core trong modern applications. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
71f5eca4 | 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. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
b886cbd2 | # 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. | API integration là core trong modern applications. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
90bec8f0 | 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. | API integration là core trong modern applications. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
1387fa0e | # 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. | API integration là core trong modern applications. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
8bf4bdec | # 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. | API integration là core trong modern applications. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
a3e2e0b3 | 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. | API integration là core trong modern applications. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
d0329895 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
d82b6ba5 | # 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. | API integration là core trong modern applications. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
fe08fed8 | # 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. | API integration là core trong modern applications. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
8ecbeabe | # 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. | API integration là core trong modern applications. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
64dfc900 | # 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. | API integration là core trong modern applications. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
4374cbec | 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. | API integration là core trong modern applications. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
9b2972c2 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
6701a84f | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
c7eb9198 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b69cd792 | 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. | API integration là core trong modern applications. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
3ea17b1a | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
b0d9b773 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
d6e9cc76 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
666fcd6e | 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. | API integration là core trong modern applications. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
85d6557e | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
595b262b | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
152eed1b | 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. | API integration là core trong modern applications. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
cd693624 | # 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. | API integration là core trong modern applications. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
14ddcd60 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
dc065670 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
5ff446b0 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
c107a375 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
f03c9944 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Base class cơ bản. **kwargs để flexible initialization. | API integration là core trong modern applications. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
9361bf6c | # 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. | API integration là core trong modern applications. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
60cd9fc2 | 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. | API integration là core trong modern applications. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
7da14ea4 | # 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. | API integration là core trong modern applications. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
74e40bde | 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. | API integration là core trong modern applications. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
1989f957 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
00d6297d | 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. | API integration là core trong modern applications. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f0103664 | # 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. | API integration là core trong modern applications. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
525342b8 | 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. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
a0fd50cf | # 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. | API integration là core trong modern applications. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
3570cd40 | # 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. | API integration là core trong modern applications. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
f9e8fa07 | 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. | API integration là core trong modern applications. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
1708d7fd | # 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. | API integration là core trong modern applications. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
7eefc433 | # 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. | API integration là core trong modern applications. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
bfbb98f9 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.