← run

he-002

1.000
1/1 tests· basic

Proposed solution

Looking at this problem, I need to extract the decimal part from a positive floating point number.

The function should:
1. Take a positive float as input
2. Return only the fractional part (decimal portion)
3. For example: 3.5 → 0.5

I can achieve this by subtracting the integer part from the original number, or more simply using the modulo operator with 1.

```python
def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """
    return number % 1
```

Test output (stdout)

.                                                                        [100%]
1 passed in 0.01s
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.