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 |
|---|---|---|---|---|---|---|---|---|
d78d6381 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
3b846a99 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Gộp nhiều dictionaries thành một. | Grouping là common operation trong data analysis. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
12c6dff8 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Gộp nhiều dictionaries thành một. | Grouping là common operation trong data analysis. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
c6cfed66 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
bd7ab63c | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
7607a3c5 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
9d391c5d | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
a8166fd5 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
76ff8f0e | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
cb30aef0 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
b8ee6308 | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
57e828ae | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
769aa223 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
19011cfe | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
34c6cf1b | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
8d97e140 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
dacdeb7b | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
a160f4ef | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
891e2029 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
608bd7de | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
64382ea9 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
9ce88966 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Grouping là common operation trong data analysis. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
28b28d7a | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
1654696a | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
fc3cbe39 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fibonacci recursive. Chậm nhưng minh họa recursion. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
bf73f62f | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fibonacci recursive. Chậm nhưng minh họa recursion. | Grouping là common operation trong data analysis. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ad19fdb | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
76b3806c | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
e6783a4a | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
eb347e0b | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
d9cafbf4 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
5f875d62 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
ec2b4164 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
5f43ad6f | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fibonacci recursive. Chậm nhưng minh họa recursion. | Grouping là common operation trong data analysis. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
121371be | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
7c1bfa58 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
953b27c4 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
f548176f | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
d87962b8 | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
b474ee49 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
13e21d92 | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
c1e023a4 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
446f9d08 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
cbc4dda8 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
d2b5743e | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
f85dfbf8 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
c3fca887 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
d53a140e | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
41d4eb72 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f2c00701 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
79a56fb0 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1239db6 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
4f0d2815 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ceeb53d | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
aaa2c5a4 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
8297b4c2 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
03588de6 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
c595e672 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
8cf20ed0 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
52ab8a6f | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
98277eef | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
5d321ba3 | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
cc185ff6 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
c8136b7b | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
6851d86a | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
02fc44ac | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
39cba728 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
c8c53e21 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
7082fc39 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
a508fe43 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
cc67703d | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Base class cơ bản. **kwargs để flexible initialization. | Grouping là common operation trong data analysis. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
7da4d592 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
9065f8a2 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
a54b7d18 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
54041e2f | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
cdb076be | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
1bd5672b | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
cb5f0bd2 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
b2f71892 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
9f38408b | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
36587669 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
8822fb77 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
339bf2c4 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
6c88bef7 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
47dfbd5d | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
da3caba5 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Decorator log_calls ghi lại mỗi lần function được gọi. | Grouping là common operation trong data analysis. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
628807de | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Decorator log_calls ghi lại mỗi lần function được gọi. | Grouping là common operation trong data analysis. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
55fee7ab | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Decorator log_calls ghi lại mỗi lần function được gọi. | Grouping là common operation trong data analysis. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
798fb2e2 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
bde9fd12 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
69bee5ee | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
0bfc6d04 | 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 | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
ebf97467 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
7f06aff4 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
2ee31eaf | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
2d28e4d0 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
bbc6ffcf | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a535aba5 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
8f557c4d | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
f9827cda | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Fetch data từ API endpoint. Trả về JSON. | Grouping là common operation trong data analysis. | python | intermediate | [
"class",
"oop"
] | 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.