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 |
|---|---|---|---|---|---|---|---|---|
a4dc5579 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
03c7c787 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
9d7ce250 | 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. | Thường dùng trong data preprocessing. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
67402c8e | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
93d9a578 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ba2719b | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
022fe0a5 | 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. | Thường dùng trong data preprocessing. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
90e2bb63 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
8febba2f | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
d8f634f9 | 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. | Thường dùng trong data preprocessing. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
f273c6c1 | # 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. | Thường dùng trong data preprocessing. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
f307b28f | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
57a4e559 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
9b83e8f9 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
0cbfa3dd | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
1817b591 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Fetch data từ API endpoint. Trả về JSON. | Thường dùng trong data preprocessing. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
ca87c206 | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
e84404ed | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
e1e65087 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
7b8b551a | 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 | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
a7a648fa | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
78925852 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
f63d2af1 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
7cb92d56 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
b560003d | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
39d4fdf9 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
0d3cd5e6 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
92e92484 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
d63e9478 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
2959a155 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
d57bea41 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
a171baca | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
d32477e9 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Extract emails từ text dùng regex pattern. | Thường dùng trong data preprocessing. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
fa51842a | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
05cb84e7 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
9ca486e9 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
ad2fbc82 | 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 | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
4c207c1c | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
8b94aa1b | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
68fea9ad | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
72447123 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
816ca9e2 | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
a6614276 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
90a954f2 | def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1)) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
d5158e77 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
06c65f46 | # Decorators
def log_calls(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
9fa65dfb | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
f2b2ce1c | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
9d68673b | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | advanced | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
cb3bc0f4 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Load JSON từ file. Trả về parsed object. | Thường dùng trong data preprocessing. | python | beginner | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
ba43d8cd | # File I/O
def read_file(path):
with open(path) as f: return f.read() | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | intermediate | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
188d1d03 | def write_file(path, content):
with open(path, 'w') as f: f.write(content) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | advanced | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
b0cd8ed7 | # Data Processing
def process_data(items):
return [x.strip().lower() for x in items if x] | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | beginner | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
bc13fce3 | 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. | Thường dùng trong data preprocessing. | python | intermediate | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
7a636a4d | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | advanced | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
ff0907f3 | def count_chars(text):
return {c: text.count(c) for c in set(text)} | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | beginner | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
87108cb3 | # Lists & Dicts
def flatten(nested):
return [item for sublist in nested for item in sublist] | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | intermediate | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
160ee0b9 | def merge_dicts(*dicts):
return {k:v for d in dicts for k,v in d.items()} | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | advanced | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
ce0e17bc | # Error Handling
def safe_int(value, default=0):
try: return int(value)
except: return default | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | beginner | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
2d77eb22 | # Algorithms
def fibonacci(n):
if n <= 1: return n
return fibonacci(n-1) + fibonacci(n-2) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | intermediate | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
bad33fa5 | 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. | Thường dùng trong data preprocessing. | python | advanced | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
de659420 | # OOP
class BaseModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def to_dict(self):
return self.__dict__ | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | beginner | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
c4f347c0 | # 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. | Thường dùng trong data preprocessing. | python | intermediate | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
ddb01034 | # Working with APIs
def fetch_data(url):
import requests
return requests.get(url).json() | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | advanced | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
528536b9 | # Regular Expressions
def extract_emails(text):
import re
return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | beginner | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
02d881f4 | # JSON Operations
def load_json(path):
with open(path) as f: return json.load(f) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | intermediate | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
65de7761 | def save_json(path, data):
with open(path, 'w') as f: json.dump(data, f) | Save data thành JSON file. | Thường dùng trong data preprocessing. | python | advanced | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
22867b3d | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
d47319d5 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
a08e6134 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
5a9bdc24 | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
0ec13913 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
1b1561fb | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
18a0ebf4 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
8ffcb795 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
a144ee97 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
de578bc4 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
2147f639 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
9ce6ac14 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
2cce5d59 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
df999b41 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
a10ed2b7 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
79cc00d8 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"json",
"file-io"
] | 3.9+ | [
"python",
"function",
"example"
] |
06407d27 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"io",
"file-operations"
] | 3.9+ | [
"python",
"function",
"example"
] |
e1020996 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"file-io",
"context-manager"
] | 3.9+ | [
"python",
"function",
"example"
] |
6f024675 | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"list-processing",
"data-structures"
] | 3.9+ | [
"python",
"function",
"example"
] |
6f016776 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"string",
"text-processing"
] | 3.9+ | [
"python",
"function",
"example"
] |
134575c7 | 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. | Grouping là common operation trong data analysis. | python | advanced | [
"grouping",
"dict"
] | 3.9+ | [
"python",
"function",
"example"
] |
c5ee7356 | # String Operations
def reverse_words(text):
return ' '.join(text.split()[::-1]) | Ghi nội dung vào file. Context manager tự động đóng file. | Grouping là common operation trong data analysis. | python | beginner | [
"string",
"manipulation"
] | 3.9+ | [
"python",
"function",
"example"
] |
b7ec4598 | 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"dict",
"counting"
] | 3.9+ | [
"python",
"function",
"example"
] |
a1de32cb | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"list",
"flattening"
] | 3.9+ | [
"python",
"function",
"example"
] |
2160b74e | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"dict",
"merging"
] | 3.9+ | [
"python",
"function",
"example"
] |
a5c48d61 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"error-handling",
"type-conversion"
] | 3.9+ | [
"python",
"function",
"example"
] |
692285bf | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"recursion",
"algorithm"
] | 3.9+ | [
"python",
"function",
"example"
] |
b1ab3c41 | 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. | Grouping là common operation trong data analysis. | python | beginner | [
"algorithm",
"math"
] | 3.9+ | [
"python",
"function",
"example"
] |
83141ea7 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"class",
"oop"
] | 3.9+ | [
"python",
"function",
"example"
] |
585faa8b | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"decorator",
"function"
] | 3.9+ | [
"python",
"function",
"example"
] |
c9775689 | # 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. | Grouping là common operation trong data analysis. | python | beginner | [
"api",
"http"
] | 3.9+ | [
"python",
"function",
"example"
] |
300a9d90 | # 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. | Grouping là common operation trong data analysis. | python | intermediate | [
"regex",
"pattern-matching"
] | 3.9+ | [
"python",
"function",
"example"
] |
7c7b8b96 | # 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. | Grouping là common operation trong data analysis. | python | advanced | [
"json",
"file-io"
] | 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.