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
826f25dd
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
1a5038d5
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
01552d0a
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
1051d64e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f15be978
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
d18f1619
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
27f239bf
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9d349c41
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
7e776eaf
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
4fafad31
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1c451ff0
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
93a986b9
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
19a437ae
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4e7e5ba9
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
f01d089b
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
306221f8
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
0354e797
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
b3861b04
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
07d437a5
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Prime checking dùng trong many algorithms.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
564b27a2
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
401d50f8
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
e0d3b0cf
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2a9a6e54
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
01f32ca5
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
49e88ecc
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
482ee8d8
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9dc699bb
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
3bb18d4e
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ec0582fb
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
90e7900a
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6b081046
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
52ad369b
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
6359d1ab
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
18a5daca
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
4a294f5a
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
23f6d0af
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
f7e6860b
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
089fdae9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
b9fb06eb
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
095985aa
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
5ea0429c
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
1452a484
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
80e77439
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9e2e27a5
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1be57294
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
852ee2f8
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6bf03fde
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
1ea376d1
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
53739810
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
95e2faa0
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5c33bf18
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f0b3e5a7
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
bc49b163
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Prime checking dùng trong many algorithms.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
96d290b5
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
bb8fbcf2
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
511e0e7c
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
1d3eb47d
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
477073c6
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
8a985b67
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d95a838d
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0290e9ce
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d70778d1
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e8f45d0d
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
b0b3c1b4
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4983056e
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d6500f13
# 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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b9dedeaa
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a72524dc
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
bb7d946b
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
833d1a70
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Prime checking dùng trong many algorithms.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
fb7d61bd
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
90b72fd2
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c273647a
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
33896ff6
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8698e7db
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
67fca45b
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
9b0aa225
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f0911f24
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b2d12373
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e5060c2f
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fbf2acad
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.
Prime checking dùng trong many algorithms.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a3add4ca
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
70034ada
# 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.
Prime checking dùng trong many algorithms.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
fb30ef1d
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a5def288
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
28562a2d
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
59f166f2
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Prime checking dùng trong many algorithms.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5b7bebaf
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
906d86b2
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
bc4131f6
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
6138e0e4
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.
Prime checking dùng trong many algorithms.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
38eac8a5
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ff20b69a
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
26d3f035
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
119d2cf7
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
89bf2050
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
0d89b3ab
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
20c2cd70
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.
Prime checking dùng trong many algorithms.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a1b34192
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Prime checking dùng trong many algorithms.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b2f83706
# 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.
Prime checking dùng trong many algorithms.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]