python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
Concept | Naming | |
---|---|---|
Function and Variable Names | Lowercase with underscores (snake_case) | string_utils.py ,math_helpers.py |
Class Names | Camel | class DataLoader: |
Global Variable (Private) | Prefix with an underscore _ | _internal_var = 42 |
No, you do not need to add a semicolon (;) at the end of every statement in Python. Python uses line breaks to determine the end of a statement, making ; optional in most cases.
Concept | Code |
---|---|
HashMap | dict() |
nums = list(set(nums)) # remove duplicates
import sys
INT_MAX = sys.maxsize # usually 2**63 - 1 on 64-bit systems
INT_MIN = -sys.maxsize - 1 # usually -2**63
max_value = float('-inf') # for smallest possible value
min_value = float('inf') # for largest possible value
# Swap elements at index 1 and 3
arr[1], arr[3] = arr[3], arr[1]
- will take up extra space
mid = left + (right - left) // 2
expected_sum = n * (n + 1) // 2
range(start, stop, step)
for i in range(10, 0, -1):
10
9
8
7
6
5
4
3
2
1