from random import randint total_attempts = 15_000_000 successful_attempts = 0 for i in range(0, total_attempts): a = randint(0, 256) b = randint(0, 256) c = randint(0, 256) if a + b + c > 300: successful_attempts += 1 print(f"Iterations: {total_attempts}") print(f"Valid sums: {successful_attempts}") print(f"Probability: {successful_attempts / total_attempts}")