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
1eb8d26a
# File I/O def read_file(path): with open(path) as f: return f.read()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
File operations là fundamentals trong programming.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
d3ed3a7b
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
File operations là fundamentals trong programming.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
8e4dca73
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
File operations là fundamentals trong programming.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
44d13d39
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
Nhóm items theo key. Tạo dictionary với key là group, value là list.
File operations là fundamentals trong programming.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
43fb3004
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
196d11b0
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.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
4a02fe1a
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c1a98787
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.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
159a418e
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f23a9ed7
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
96c21dd5
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.
File operations là fundamentals trong programming.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
45cd19ba
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
39a462c0
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
c5382a6a
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
d4d5ab2a
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
e1df222f
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e291b056
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.
File operations là fundamentals trong programming.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
1c0d6298
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
40a7bd7e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
File operations là fundamentals trong programming.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d08d9fcd
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
f84a7c76
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.
File operations là fundamentals trong programming.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
1af3859a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
File operations là fundamentals trong programming.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
91282a13
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a2b952f5
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
e5b3ba89
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.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
37e81b0d
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
05898e22
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
612bc591
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.
File operations là fundamentals trong programming.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
0a2e7af2
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
feda0352
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
7acfa6aa
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
File operations là fundamentals trong programming.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
a344ce90
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0a8a8a2d
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
cff9bd4e
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.
File operations là fundamentals trong programming.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
46c5650e
# 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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
7b862751
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ự.
File operations là fundamentals trong programming.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f8643d6a
# 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ự.
File operations là fundamentals trong programming.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
a5eaefb2
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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7d6198d1
# 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ự.
File operations là fundamentals trong programming.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
d8f4d720
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ự.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d7e84a56
# 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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a2fad77b
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ự.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a1192b2d
# 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ự.
File operations là fundamentals trong programming.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
19c3f6ea
# 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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
666629bb
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ự.
File operations là fundamentals trong programming.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
cd1cf282
# 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ự.
File operations là fundamentals trong programming.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
39ec67eb
# 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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0bbb85c9
# 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ự.
File operations là fundamentals trong programming.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5d942736
# 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ự.
File operations là fundamentals trong programming.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0c8c77b7
# 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ự.
File operations là fundamentals trong programming.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
0a36ad01
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ự.
File operations là fundamentals trong programming.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
85b47959
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
566717e4
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
File operations là fundamentals trong programming.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
02d26fe5
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
3d4baac3
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.
File operations là fundamentals trong programming.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
70484a58
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
48198866
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
331b0082
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
21ff7008
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.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
0f261d02
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8a0df07e
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3c16e2b0
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.
File operations là fundamentals trong programming.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
02c758d1
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5cf3e6b0
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
18811607
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
File operations là fundamentals trong programming.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
684a80f8
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0e58b253
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
6f9d1897
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.
File operations là fundamentals trong programming.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7dd87b35
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
569bbb3e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
fd084519
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
9ba1c166
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.
File operations là fundamentals trong programming.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
66ffeb3f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
2aafab3b
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
a9d3591b
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8b624c10
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.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a4ae37d0
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
3ffab104
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
30207812
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.
File operations là fundamentals trong programming.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f6e5db3f
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
24491343
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
e6d67dda
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
4e30664a
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
29763dbf
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9bb9b3c5
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
File operations là fundamentals trong programming.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
49d22766
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
286e4760
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.
File operations là fundamentals trong programming.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
ae48f7f2
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
8f9acc97
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.
File operations là fundamentals trong programming.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
e7e005a6
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
f3e5541d
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.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8ff77926
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c8d34172
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.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
11d35f7a
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f8123350
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
be517b12
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.
File operations là fundamentals trong programming.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
446a3b42
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
d0b1651b
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
773b52f2
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
faee894a
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]