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
4d64e3dc
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
51c4e5d1
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
5a177ed6
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ea5940c6
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7fc8d76c
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5d620065
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
0c881d44
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
ea2e7209
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
ca744fcc
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0220ba8c
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
String manipulation dùng .split() và slicing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
e91d40af
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
b53bfd6e
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
5af2e44f
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
bdc29410
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
56667d73
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
2155bc77
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
26bc3223
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
964315c8
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4b6935e8
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d617e77e
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f0f7c463
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
6c6a9d07
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
248586e6
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
312683bf
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
da752a6e
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
01fbecd0
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
69310da5
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
9363c14d
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9f8b1429
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
252500ae
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
String manipulation dùng .split() và slicing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7f01bb02
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
da17ba32
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
533544de
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f2e00bc1
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7b83f170
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
764e09aa
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
89c8b670
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9781db4a
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
000af5ba
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ed59e0ff
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fbac5f6f
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
3156d42b
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
84e252a0
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b8f0e592
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
0b1e3a57
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
7974fcf9
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
fccefc3a
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
eff4cb38
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
113358ea
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
String manipulation dùng .split() và slicing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
8ea7283f
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
444802f7
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
ffd04858
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
70a6ce4e
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e1f23c2b
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f7517e21
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
623cb661
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
646ac9ce
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
0224bcb8
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f7ae01d3
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
1ffa65c0
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
eb37bc53
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
String manipulation dùng .split() và slicing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
bb4ae447
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9b46e388
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
84d295f1
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
4857f8c5
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ad10a625
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
738b6be0
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5b41835f
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
300894fb
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
40fbe6d4
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a4f56890
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
4ca99075
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9b1397d1
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
bfea2fd5
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
8d6c8b7e
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
2a40b433
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c324f33d
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
a2218f9f
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
c0790477
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
38702a46
# 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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8c408654
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.
String manipulation dùng .split() và slicing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7f5e9fef
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d3fef106
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
72d78c81
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8b7fff07
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
2dbdd602
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a3107348
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d6b8e228
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
708fe4df
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
7a66a6a3
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a49a5172
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
43a7080f
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.
String manipulation dùng .split() và slicing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
166049f6
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e54250ac
# 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.
String manipulation dùng .split() và slicing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ec1c8617
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
c3210a6b
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
816dce19
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
806dcefa
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
String manipulation dùng .split() và slicing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
27b092fe
# 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.
String manipulation dùng .split() và slicing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
cbda0ebf
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.
String manipulation dùng .split() và slicing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]