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 |
|---|---|---|---|---|---|---|---|---|
a2f296bb | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
4caafc8e | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
8edd8f57 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
8f1541fd | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
46c1bfce | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
ab8236d0 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
0e07f3aa | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a718d921 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
2a4f9f1d | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
81a11bb5 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
ee7cb86a | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
4c15df0b | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
601ea1ef | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
e9a22049 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6be88e5a | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Save data thành JSON file. | Recursion là important concept nhưng cần cẩn thận performance. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
d0377a86 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
956fc491 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
9d9ce7f1 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
beffec15 | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
24387c3b | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
3e2e51e0 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
7c4e868d | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
489c2b20 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
74adef53 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
9cc4f564 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
8f0aaded | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
bddf60a8 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
498627fb | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
fe6aa4f9 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
079e2eca | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
ca54432f | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
46b007a0 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Hàm này đọc nội dung của file và trả về dưới dạng string. | Prime checking dùng trong many algorithms. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
ea27a709 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
350eb47b | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
79ef9a46 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b7173b34 | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
ea5c75ca | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
f65b4eee | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
b7820bbd | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
429a7fef | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
904f8d7a | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
81e30c91 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
243f435d | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
e738bb50 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
34dff0ae | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
e0010691 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
a8951897 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
de037fe8 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6e047759 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Ghi nội dung vào file. Context manager tự động đóng file. | Prime checking dùng trong many algorithms. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
791b4a72 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
c327f5b3 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
140713c8 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b8ff311a | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
f0ffb193 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
76bfbcc9 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
aba6fade | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
8e989aa3 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
9c1d9f58 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Xử lý danh sách: strip spaces, convert to lowercase, filter empty. | Prime checking dùng trong many algorithms. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
65e36947 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
4f87b9c5 | 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
001767d9 | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
fddb5b10 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
5bc5d766 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
f756a870 | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
b27176fe | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
b2bdaf9a | 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
58b1a5dc | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
41859119 | 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
05ed7acd | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
c4e3d27e | 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
5289fabc | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
db380659 | 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
4b6b8a04 | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
cb6cebd5 | 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
5f504ef2 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a38285d7 | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
61c2ce83 | 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
f3bb0f43 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
dd09a76e | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
c8a85169 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
4156e3d8 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
8e6b6137 | # 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ccecb40 | 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
bbc17307 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
f0c19125 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Đảo ngược thứ tự các từ trong text. | Prime checking dùng trong many algorithms. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
63b7c9e6 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
97066382 | 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
80bc3e13 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Đảo ngược thứ tự các từ trong text. | Prime checking dùng trong many algorithms. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
faa31c35 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Đảo ngược thứ tự các từ trong text. | Prime checking dùng trong many algorithms. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
25fec51c | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
f9c95ba8 | 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
60d16d52 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
d1166845 | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
1aaeca1a | 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
b95364d3 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
cc914d1b | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
2173dd04 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Đảo ngược thứ tự các từ trong text. | Prime checking dùng trong many algorithms. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
01a6fd96 | # 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. | Prime checking dùng trong many algorithms. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
c4b03bac | # 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. | Prime checking dùng trong many algorithms. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
9f09a471 | 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. | Prime checking dùng trong many algorithms. | python | beginner | [
"io",
"file-operations"
] | 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.