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 |
|---|---|---|---|---|---|---|---|---|
523fa6ac | 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ự. | Try-except pattern cho error handling. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
8a947416 | # 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ự. | Try-except pattern cho error handling. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
4c2cb596 | 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ự. | Try-except pattern cho error handling. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
b883587b | # 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ự. | Try-except pattern cho error handling. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
d60a1419 | 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ự. | Try-except pattern cho error handling. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
c5a75d71 | # 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ự. | Try-except pattern cho error handling. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a653b5cd | # 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ự. | Try-except pattern cho error handling. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
43a8fabb | 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ự. | Try-except pattern cho error handling. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
c095ab6c | # 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ự. | Try-except pattern cho error handling. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
8aa7c693 | # 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ự. | Try-except pattern cho error handling. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
6fa5b728 | # 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ự. | Try-except pattern cho error handling. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
db119e6f | # 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ự. | Try-except pattern cho error handling. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
0111e106 | # 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ự. | Try-except pattern cho error handling. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
651afd74 | 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ự. | Try-except pattern cho error handling. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
945bce20 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
8774371a | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Làm phẳng list nested thành flat list. | Try-except pattern cho error handling. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
139c2233 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
699a140e | 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. | Try-except pattern cho error handling. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
8082b06d | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Làm phẳng list nested thành flat list. | Try-except pattern cho error handling. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
6f5ef6d6 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Làm phẳng list nested thành flat list. | Try-except pattern cho error handling. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
c3b6f496 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
66d1e48f | 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. | Try-except pattern cho error handling. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
97be78bc | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
639ac001 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
d5b993c0 | 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. | Try-except pattern cho error handling. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
98e0b9e7 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
e3007685 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
dc0259fb | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Làm phẳng list nested thành flat list. | Try-except pattern cho error handling. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
598b0213 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
5353db2d | # 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. | Try-except pattern cho error handling. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
6fa532c1 | 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. | Try-except pattern cho error handling. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
a8f55c1f | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
4e4fc334 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
aa4d87c9 | # 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. | Try-except pattern cho error handling. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
660a8f15 | 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. | Try-except pattern cho error handling. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
61c1b579 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
7ff0429c | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
08a19210 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
a994b2a0 | 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. | Try-except pattern cho error handling. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
18b78da6 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
6562b824 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
4b8ef846 | 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. | Try-except pattern cho error handling. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
7f20ae9b | # 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. | Try-except pattern cho error handling. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
0e61e654 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
3a4c141a | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
155127ae | # 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. | Try-except pattern cho error handling. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
06b8bae3 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
0f07f6ac | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Gộp nhiều dictionaries thành một. | Try-except pattern cho error handling. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
22119dcd | # 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. | Try-except pattern cho error handling. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1defea4 | 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. | Try-except pattern cho error handling. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
1acd7d88 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
62ea601a | 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. | Try-except pattern cho error handling. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
3d7f061f | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
33d9a927 | 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. | Try-except pattern cho error handling. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
fca8201d | # 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. | Try-except pattern cho error handling. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
73a34758 | 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. | Try-except pattern cho error handling. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
863f22f6 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
113c076b | # 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. | Try-except pattern cho error handling. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
4ead5f93 | 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. | Try-except pattern cho error handling. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
49819a27 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
32ef92d8 | # 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. | Try-except pattern cho error handling. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
71473aa8 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
13c09ac7 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
b9b4ce75 | # 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. | Try-except pattern cho error handling. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
c582f92c | 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. | Try-except pattern cho error handling. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
d6a88092 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
3d56b5c6 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
080c2c70 | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
89f53452 | 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. | Try-except pattern cho error handling. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
2221bb94 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
bd13b68b | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
bf88e202 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
79bb15d8 | 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. | Try-except pattern cho error handling. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
3ea59fda | # 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. | Try-except pattern cho error handling. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
6247e575 | # 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. | Try-except pattern cho error handling. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
055ae810 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
ec6143b3 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
a55e8c02 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
89830f1d | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
29a33df2 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
268e0501 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
7023d120 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Try-except pattern cho error handling. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
ad9ab94e | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
52fa980d | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
2ddb149c | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
b321903f | def group_by_key(items, key):
result = {}
for item in items:
k = item.get(key)
if k not in result: result[k] = []
result[k].append(item)
return result | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
ba553f0f | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
580fbe93 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
ada55c91 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
d312d713 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
e2d6fc57 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
76afea7e | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
325c524a | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
5e2e0770 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f9dc7503 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
49defa39 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
6d587af9 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
9f51ef34 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
8c34bdef | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors. | Try-except pattern cho error handling. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
b137e098 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Base class cơ bản. **kwargs để flexible initialization. | Try-except pattern cho error handling. | python | beginner | [
"file-io",
"context-manager"
] | 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.