We are given the function:
\[
f(x) = |\sin x| + |\cos x|.
\]
We need to find the period of this function.
Step 1: To determine the period of \( f(x) \), we need to analyze the behavior of \( |\sin x| \) and \( |\cos x| \). Both \( \sin x \) and \( \cos x \) have a period of \( 2\pi \), but since they are both taken as absolute values, the function \( f(x) \) will have a shorter period.
Step 2: Consider the behavior of \( f(x) \) in the interval \( [0, \pi] \):
- On the interval \( [0, \frac{\pi}{2}] \), both \( \sin x \) and \( \cos x \) are non-negative, so \( f(x) = \sin x + \cos x \).
- On the interval \( [\frac{\pi}{2}, \pi] \), \( \sin x \) is positive, but \( \cos x \) is negative, so \( f(x) = \sin x - \cos x \).
- The function \( f(x) \) repeats this pattern on subsequent intervals of length \( \pi \).
Step 3: Therefore, the function \( f(x) \) has a period of \( \frac{\pi}{2} \).
Thus, the period of \( f(x) \) is \( \frac{\pi}{2} \).
Therefore, the correct answer is option (D).