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
d5413c4f
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
f93885ac
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
47adee05
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
48e196c9
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
badf700a
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
94fac210
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
3aed5a9e
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
be868fef
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
98b45f42
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8aa5a6b1
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d5655971
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a192529a
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
963c512f
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
911313aa
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
2a50e632
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e31356d5
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
bbb9500f
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
caba3523
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
40badc45
# 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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2a38844a
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
4cfda3c1
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
421fc6b4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ccdc1058
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
95cde14e
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
0957031c
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
db491766
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
dddeb4fe
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a0cfcfc6
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
41551371
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
82a48014
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f2c9eaf7
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
3ef52a52
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
82e84388
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
e2146f22
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.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
dff92140
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c0f43b16
# 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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f38f5a34
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ade299ae
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5aa2a730
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ed2adcf0
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
f01a20e8
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
150abe53
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
522bdca0
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
fef9fd94
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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3e84201c
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ad06add3
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
81a34438
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c019487a
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
0f7a7dfc
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
011b17c0
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
8b80a014
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.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
84df8b8a
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
86647746
# 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.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
b556d540
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
8d8254bf
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
a9fc3731
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
fe4ac5cf
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Decorators enhance function behavior mà không modify source.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
35888cf1
# 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.
API integration là core trong modern applications.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
a47d36bf
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.
API integration là core trong modern applications.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
5fd19ad6
# 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.
API integration là core trong modern applications.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4246074a
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.
API integration là core trong modern applications.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
c3ff57d8
# 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.
API integration là core trong modern applications.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
e14380f0
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.
API integration là core trong modern applications.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
9df431db
# 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.
API integration là core trong modern applications.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8a69e0d5
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.
API integration là core trong modern applications.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b64856c1
# 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.
API integration là core trong modern applications.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
2c016152
# 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.
API integration là core trong modern applications.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3c215fe5
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.
API integration là core trong modern applications.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4b6de426
# 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.
API integration là core trong modern applications.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
6ecb1860
# 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.
API integration là core trong modern applications.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
d3c9201d
# 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.
API integration là core trong modern applications.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
b1d03dc3
# 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.
API integration là core trong modern applications.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
b06416a7
# 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.
API integration là core trong modern applications.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
87b4aa58
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.
API integration là core trong modern applications.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
988f63fb
# 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.
API integration là core trong modern applications.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
488905aa
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.
API integration là core trong modern applications.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
9d1e96cd
# 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.
API integration là core trong modern applications.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
653a90b3
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.
API integration là core trong modern applications.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
79fa0530
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
API integration là core trong modern applications.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
e69fad8d
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.
API integration là core trong modern applications.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a8433386
# 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.
API integration là core trong modern applications.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d8c002d3
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.
API integration là core trong modern applications.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ece1cfed
# 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.
API integration là core trong modern applications.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8e59395b
# 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.
API integration là core trong modern applications.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9f536f48
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.
API integration là core trong modern applications.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
82ccdad3
# 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.
API integration là core trong modern applications.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
0eca15e8
# 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.
API integration là core trong modern applications.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0eadad5f
# 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.
API integration là core trong modern applications.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
604cfc89
# 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.
API integration là core trong modern applications.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
e4c0449c
# 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.
API integration là core trong modern applications.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
42825aa1
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Ghi nội dung vào file. Context manager tự động đóng file.
API integration là core trong modern applications.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6e8cb799
# File I/O def read_file(path): with open(path) as f: return f.read()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
9b250698
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0c44c4f3
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
be740ef9
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
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
33a6172f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
e44f637e
def count_chars(text): return {c: text.count(c) for c in set(text)}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
044e4dc7
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d687be72
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
cb8a30ac
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
API integration là core trong modern applications.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]