• + 0 comments
    #The formula for the geometric distribution probability: (P(X = k) = (1-p)^{k-1}p),
    # Define the probability of success on a single trial
    p = 1/3
    
    # Initialize the probability of finding the first defect in the first 5 inspections
    prob = 0
    
    # Loop over the first 5 inspections
    for k in range(1, 6):
      # Calculate the probability of finding the first defect on the k-th inspection
      prob_k = (1-p)**(k-1) * p
    
      # Add this probability to the total probability
      prob += prob_k
    
    # Print the final probability
    print(round(prob, 3))