We form a decimal code of $21$ digits. the code may start with $0$. Determine the probability that the fragment $0123456789$ appears in the code.
1. **Total Number of Codes**: 
   The total number of possible 21-digit codes is \(10^{21}\). This is because each digit can be any of the 10 digits (0 through 9), and there are 21 positions.

2. **Counting Codes with the Fragment \(0123456789\)**:
   - Consider the fragment \(0123456789\) as a single "block" within the 21-digit code.
   - This block can start at any of the first 12 positions in the 21-digit code. If it starts at position 1, it occupies positions 1 through 10; if it starts at position 2, it occupies positions 2 through 11, and so on up to starting at position 12, which occupies positions 12 through 21.
   - For each of these 12 starting positions, the remaining 11 positions in the code can be filled with any of the 10 digits. Therefore, there are \(10^{11}\) ways to fill the remaining positions for each starting position of the block.

3. **Total Number of Codes with One Block**:
   - Since there are 12 possible starting positions for the block \(0123456789\), and for each starting position there are \(10^{11}\) ways to fill the remaining positions, the total number of codes with at least one occurrence of the block is \(12 \cdot 10^{11}\).

4. **Adjusting for Overcounting**:
   - Some codes may contain the block \(0123456789\) more than once, and these have been counted multiple times in the previous step.
   - To correct for this, we need to subtract the number of codes that contain the block \(0123456789\) at least twice.
   - If the block appears twice, the first block can start at any of the first 3 positions (since the second block must start at least 10 positions after the first block starts). For each of these 3 starting positions, the remaining 1 position can be filled with any of the 10 digits. Therefore, there are \(3 \cdot 10\) such codes.

5. **Final Probability Calculation**:
   - The total number of codes with at least one occurrence of the block \(0123456789\) is \(12 \cdot 10^{11}\).
   - The number of codes with at least two occurrences of the block \(0123456789\) is \(30\).
   - Therefore, the number of codes with exactly one occurrence of the block \(0123456789\) is \(12 \cdot 10^{11} - 30\).
   - The probability \(p\) that a randomly chosen 21-digit code contains the block \(0123456789\) is given by:
     \[
     p = \frac{12 \cdot 10^{11} - 30}{10^{21}}
     \]

The final answer is \( \boxed{ \frac{12 \cdot 10^{11} - 30}{10^{21}} } \).