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
87a34b7a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7ad34540
def count_chars(text): return {c: text.count(c) for c in set(text)}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
5d090b96
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8b54481e
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
c8b73e9a
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ee6a34da
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6018dcd5
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
ab857817
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
27063a4c
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
8bcbb662
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
6ffc4821
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
57ac0795
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
a2c858b7
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
0c59fefc
# File I/O def read_file(path): with open(path) as f: return f.read()
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
42677b0d
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c428025f
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2e1bed55
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
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
59d481af
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
f703035c
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f5f80a93
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
474077b8
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1c6470ff
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
58e45b07
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
7835cc9b
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c0fb043a
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
41466390
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0fce5505
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
998d74aa
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
3e8ca72b
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
78af6457
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
1b067845
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
4fa24911
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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
bf77fc78
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
cac30a3c
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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
916b1f41
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d8824d39
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ự.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
265eac1f
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
85051dad
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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
e8131677
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8a585727
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
38af33b3
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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
72445bd7
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
23c6f4c0
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
626e11a2
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f8e4c5ce
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
a9a51d30
# 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ự.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
89ae643a
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ự.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
8938b4c4
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
96c0cc78
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
130a1cbf
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
7e872c73
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
5d2cf9ea
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
9051a7b4
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
908613c3
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
b7681dde
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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9dc3dce9
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
75a6f28b
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
85d4e2e5
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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a0021a09
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c94df42b
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
28e8454e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
3794723a
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
89d2f9f5
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
f4017262
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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
cac7b31c
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ea40ac2e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
8093baf9
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
0f0a9eaf
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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
2bfba0a8
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
e38d4400
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
2e908697
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f6740b92
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
523bda7a
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ff981542
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
5b5f6fd0
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d1057ef2
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
44bb2259
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
63b0caa8
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
64d460dd
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5f972e85
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
b432ab3a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
cccfd89b
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ff8e9097
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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
6c5e6872
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f0fd188c
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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
e346f229
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
23311bd1
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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c1e1967e
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a5a94525
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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
924ac628
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d58dc234
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
7bc7b692
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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b91f1a71
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
828da3c4
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
e8ed025a
# 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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
260fa467
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
af57bcba
# 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.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
010ef51e
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.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
ac81d708
# 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.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
1f83881b
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fibonacci recursive. Chậm nhưng minh họa recursion.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]