Format a byte count using binary units: B, KiB, MiB, GiB, TiB, PiB (factor 1024). Use the largest unit in which the value is at least 1, with one decimal place, except bytes, which are shown as an integer.
Examples: 512 → "512 B", 1536 → "1.5 KiB", 1048576 → "1.0 MiB".
Implement human_bytes. Input: n: int. Returns: str.
def human_bytes(n: int) -> str:
return f"{n} B"
Run executes the public tests. Submit grades against public and hidden tests.
Format a byte count using binary units: B, KiB, MiB, GiB, TiB, PiB (factor 1024). Use the largest unit in which the value is at least 1, with one decimal place, except bytes, which are shown as an integer.
Examples: 512 → "512 B", 1536 → "1.5 KiB", 1048576 → "1.0 MiB".
Implement human_bytes. Input: n: int. Returns: str.
def human_bytes(n: int) -> str:
return f"{n} B"
Run executes the public tests. Submit grades against public and hidden tests.