Skip to content

Commit 8aab9a2

Browse files
Update cli.py
1 parent d0c764c commit 8aab9a2

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

probability_calculator/cli.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,50 @@
55

66
def main():
77
parser = argparse.ArgumentParser(
8-
description="Probability Calculator — Monte-Carlo simulation for drawing balls from a hat."
8+
description=(
9+
"Probability Calculator — Monte-Carlo simulation for drawing "
10+
"colored balls from a hat."
11+
)
912
)
1013

1114
parser.add_argument(
1215
"--hat",
1316
nargs="+",
14-
help="Colors and counts, e.g. red=3 blue=2",
17+
help="Colors and counts: e.g. red=3 blue=2 green=6",
1518
)
19+
1620
parser.add_argument(
1721
"--expect",
1822
nargs="+",
19-
help="Expected ball counts, e.g. red=2 blue=1",
23+
help="Required minimum colors: e.g. red=2 green=1",
24+
)
25+
26+
parser.add_argument(
27+
"--draw",
28+
type=int,
29+
help="Number of balls to draw.",
30+
)
31+
32+
parser.add_argument(
33+
"--experiments",
34+
type=int,
35+
help="Number of Monte-Carlo experiments.",
2036
)
21-
parser.add_argument("--draw", type=int, help="Number of balls drawn")
22-
parser.add_argument("--experiments", type=int, help="Number of experiments")
2337

2438
args = parser.parse_args()
2539

40+
# Must pass all required arguments
2641
if not (args.hat and args.expect and args.draw and args.experiments):
2742
parser.print_help()
2843
return
2944

30-
# Convert hat arguments
45+
# Parse hat contents
3146
hat_kwargs = {}
3247
for item in args.hat:
3348
color, count = item.split("=")
3449
hat_kwargs[color] = int(count)
3550

51+
# Parse expected outcome
3652
expected = {}
3753
for item in args.expect:
3854
color, count = item.split("=")

0 commit comments

Comments
 (0)