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
19abfafa
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
39eca3fe
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
fdedb1e6
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
3ef03d68
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ebd69d89
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
bcd06c2d
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
b6e582b8
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9b04ca77
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đảo ngược thứ tự các từ trong text.
Merging dictionaries là common trong config management.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
e7094da9
# File I/O def read_file(path): with open(path) as f: return f.read()
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
91aacbb2
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d34629d8
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
df1e999b
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
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
3a0d4e5f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
27b2355b
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
726b6148
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f52e2ab2
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ce043860
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
85a56419
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
aa8ce497
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
2a676042
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
12d36c65
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
8c564b6b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a5e196cb
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
9c30fb11
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
dedaf016
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đếm tần suất xuất hiện của mỗi ký tự.
Merging dictionaries là common trong config management.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
3a6125d9
# File I/O def read_file(path): with open(path) as f: return f.read()
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
5602c462
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
a88192fd
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
49ac7dd6
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
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
320ad05f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
39403430
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f18917f5
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
7fc1a262
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.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ccd6de29
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
af07d153
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
65005657
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.
Merging dictionaries là common trong config management.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
165ac794
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
781ca3e0
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
284dbf23
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Merging dictionaries là common trong config management.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
722cc5ed
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0313b7a4
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
80a2455c
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.
Merging dictionaries là common trong config management.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
45892c22
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d7b4e9e9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c6662fb7
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
fa7346a2
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.
Merging dictionaries là common trong config management.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
31f2e852
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
13109dc8
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
0b30e8fb
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
05cd2ab0
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
041911af
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
bb6a7007
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
10cce347
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
0cd67671
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
68dc0448
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
3a855839
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
733d777f
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
2da655c4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8c902141
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Merging dictionaries là common trong config management.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5aba6373
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d4c8a65a
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.
Merging dictionaries là common trong config management.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
073f0dd6
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
6bdfeac1
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.
Merging dictionaries là common trong config management.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
c510a38f
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
a9c7cae1
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
42931f25
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
730b5158
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.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
99100e1a
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
11e3808f
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
42b0ad74
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.
Merging dictionaries là common trong config management.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d889cc35
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
991c60c8
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f24f6eb2
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f99308af
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
50f52108
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
216f7da8
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.
Merging dictionaries là common trong config management.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6a235c4b
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6aa5b2ab
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Merging dictionaries là common trong config management.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
cc1a6d9f
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
a793f81c
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1b9d3161
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fibonacci recursive. Chậm nhưng minh họa recursion.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9fc4c2b2
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fibonacci recursive. Chậm nhưng minh họa recursion.
Merging dictionaries là common trong config management.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
e381dcee
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
36fb927e
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.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d49305cc
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ae338844
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
83351ae9
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.
Merging dictionaries là common trong config management.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
25381d21
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
74462566
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
66095092
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Merging dictionaries là common trong config management.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a4e36bec
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c99a5bb0
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
b490085b
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.
Merging dictionaries là common trong config management.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
acb68dc2
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
6f6a3211
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.
Merging dictionaries là common trong config management.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
7c81d8be
# 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.
Merging dictionaries là common trong config management.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
3a446f70
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.
Merging dictionaries là common trong config management.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a87a90ca
# 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.
Merging dictionaries là common trong config management.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6e9f26ea
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.
Merging dictionaries là common trong config management.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8ababf2d
# 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.
Merging dictionaries là common trong config management.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]