x if condition else y
2 if b % 2 == 0 else 1 is a one-line choice: it gives 2 when the condition is true and 1 when it isn't. You can use it anywhere a value goes.
Challenge A:Loop 1-8 and play hihat(b, 2 if b % 2 == 0 else 1) — two hits on even beats, one on odd.