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 |
|---|---|---|---|---|---|---|---|---|
28f8cbc8 | # 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. | API integration là core trong modern applications. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
b93d35f4 | 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. | API integration là core trong modern applications. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ae622c7e | # 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. | API integration là core trong modern applications. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
3f6212af | # 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. | API integration là core trong modern applications. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
e30187d3 | # 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. | API integration là core trong modern applications. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
aba70122 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
d7a68ddd | # 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. | API integration là core trong modern applications. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
4a79adb4 | 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. | API integration là core trong modern applications. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
32fbc480 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
87d775ab | 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. | API integration là core trong modern applications. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
dfcaf3a0 | # 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. | API integration là core trong modern applications. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
142acef1 | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
15a1da64 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
92ea20bd | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f715acc7 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
124bed6e | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
9840cb5b | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
7156c6cb | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
1afec037 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
e4c8c264 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f70ae3d1 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
61e6bdde | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
8e13356e | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
ff31cb77 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
d72d410a | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Nhóm items theo key. Tạo dictionary với key là group, value là list. | API integration là core trong modern applications. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
dd96853a | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
579bf78b | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
f2b9ad18 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
09b7036e | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
d5561027 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
397bad2a | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
593a153d | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
9fa5e117 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
610035f6 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
428f076d | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
1697210d | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
8267a1ee | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
3f420706 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
a509df00 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
c5fc16ef | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
1cbcd128 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
87e6eae0 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Đảo ngược thứ tự các từ trong text. | API integration là core trong modern applications. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
34089a9e | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
694fef17 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
8956e7b0 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
a20da9c9 | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
68712750 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
e332c697 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f0a7c616 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
5a69cc87 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
1c6b97aa | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a9c7d979 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
73187b2b | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
4b314f67 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
1aa9e835 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1a0a6fc | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
dc766c7b | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
337f0978 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
b5a2dbc4 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Đếm tần suất xuất hiện của mỗi ký tự. | API integration là core trong modern applications. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
d9ce0667 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
67541876 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
5a971f8e | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
af1d5007 | 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 | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
6f793f17 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
70e22ce4 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
ed0e9e0a | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
008dda62 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
27796727 | # 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. | API integration là core trong modern applications. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
3440b539 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
ce7360e8 | 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. | API integration là core trong modern applications. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
00d221b3 | # 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. | API integration là core trong modern applications. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
8919363d | # 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. | API integration là core trong modern applications. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
a88db4df | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Làm phẳng list nested thành flat list. | API integration là core trong modern applications. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
7b18adc8 | # 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. | API integration là core trong modern applications. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
cbb8d662 | # 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. | API integration là core trong modern applications. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
50749ca8 | 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 | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
436750c2 | # 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 | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
0123ed09 | 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 | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
35fb170d | # 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 | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
ccb0151e | 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 | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
76615878 | # 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 | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
48fc3ce4 | 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 | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
c5cfc672 | # 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 | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
d4ef8237 | 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 | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
08c41013 | # 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 | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
d593f7ad | # 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 | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
aa9b689f | 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 | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
23a06c11 | # 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 | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
558169d6 | # 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 | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
0744ddf2 | # 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 | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ef8e07d | # 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 | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
35b719b7 | # 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 | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
05e2b01f | 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 | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
e822bc90 | # 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 | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
67fc9f11 | 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 | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
f87e77f5 | # 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 | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
1c10dddf | 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 | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
f66d36ee | # 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 | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
0710541f | 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 | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
dbd75eb6 | # 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 | advanced | [
"list",
"flattening"
] | 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.