Complement Rule: P(not A) = 1 − P(A)

Basics
BasicsAxiomsGoogleMetaJane Street

Problem

Implement complement_prob(p_a) returning the complement probability P(Ac)=1−P(A)P(A^c) = 1 - P(A) as a Python float.

Why It Matters: Many tricky interview problems ('at least one failure', 'at least two people share a birthday') become trivial once flipped via the complement rule.

Function Signature

def complement_prob(p_a: float) -> float:

Sample Input & Output

Example 1: Standard Probability

Input:

p_a = 0.35

Expected Output:

0.65

Explanation: If an event occurs with probability 0.35, it does NOT occur with probability 1 - 0.35 = 0.65.

Example 2: Boundary Probabilities

Input:

p_a = 1.0

Expected Output:

0.0

Explanation: A certain event (1.0) has complement probability 0.0.

Constraints & Edge Cases

  • 0.0 <= p_a <= 1.0.
  • Guaranteed 0.0 <= p_a <= 1.0.
  • Return float(1.0 - p_a).

Constraints & Evaluation Criteria

  • `0.0 <= p_a <= 1.0`.

Hints

Python 3
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
p_a = 0.3
Expected Output / Criteria
0.7