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
9ae82b29
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7702de8d
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
25e65272
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ce278161
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8c3fe596
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
734fc2c1
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2370005f
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.
JSON là standard format cho data interchange.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f7a3eb60
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b146c5cf
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
424e272f
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
93e4ce94
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
cb3d74d9
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
aeacc1ab
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.
JSON là standard format cho data interchange.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0a396b62
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
60ec3761
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
JSON là standard format cho data interchange.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
a09b4268
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
93387549
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.
JSON là standard format cho data interchange.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d6a55e2a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
JSON là standard format cho data interchange.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
b2b4e682
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
04aa983e
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d230862d
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a6898e20
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f41151a4
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
aa252a71
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.
JSON là standard format cho data interchange.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
100e0477
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
bc6a52fa
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
54293b8a
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
JSON là standard format cho data interchange.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d5458013
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f661d020
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
7dadf452
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.
JSON là standard format cho data interchange.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
fe84cc89
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
0e233d20
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.
JSON là standard format cho data interchange.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
e3414b09
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
88307757
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.
JSON là standard format cho data interchange.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
675b5e77
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6b084785
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
cf7b22df
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
033b25bf
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
cde73fd7
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
99761f35
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9b5a4ef8
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.
JSON là standard format cho data interchange.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
8c26fb4a
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
bc2cc8e5
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
5d908496
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
708d5b2d
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
da821a80
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
c75b1fa6
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.
JSON là standard format cho data interchange.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
262f3dd3
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ccd415b4
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
1afce551
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
95079a75
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.
JSON là standard format cho data interchange.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
2422f8e7
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ef5d71c8
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
76b5b3ce
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a618ce3a
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
23bf8fd3
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
dcd9f794
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
8820b5d3
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.
JSON là standard format cho data interchange.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
64fd161e
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
70ffe5b0
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
6b1026ea
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
006faba9
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8a9666b9
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f53192a5
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
JSON là standard format cho data interchange.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
188cc614
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
032bb434
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.
JSON là standard format cho data interchange.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
99d2b17f
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
79ac2f29
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.
JSON là standard format cho data interchange.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
d2e50a3c
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a60cb576
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
af172a37
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9b095f48
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
62b5ca17
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
fccf9bec
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
9b4c2960
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.
JSON là standard format cho data interchange.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
fbdeaec5
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
04fdc6d5
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
900ed510
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
78a683e3
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8a74b83d
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4c3e0ee8
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.
JSON là standard format cho data interchange.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
61552ebf
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
23e07e3d
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
516f2da3
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7a8c0e88
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.
JSON là standard format cho data interchange.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
ad5a2de0
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
15c6e1a9
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d727d4bc
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a069fed0
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.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
5557f27a
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
aae7213a
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2ed2b25d
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.
JSON là standard format cho data interchange.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
9ea37e8e
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
faa1ef45
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2e1dacc6
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d95344ee
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
de3876d7
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a885007e
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
JSON là standard format cho data interchange.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
fec86779
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
eee93b51
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]