From: tomás zerolo Date: Sun, 20 Nov 2022 15:30:19 +0000 (+0100) Subject: Two off-by-one errors X-Git-Url: http://git.tuxteam.de/gitweb/?a=commitdiff_plain;h=43ddd0e5d22d80fa3413ad9076444cc7cf05eb09;p=susannes-git%2Fmathe%2Fstats%2Fbernoulli.git Two off-by-one errors --- diff --git a/coinflip.py b/coinflip.py index 7a5f62d..7ed6598 100755 --- a/coinflip.py +++ b/coinflip.py @@ -4,7 +4,7 @@ import sys from random import random def flipcoins (n): - return [int(2*random()) for i in range(n-1)] + return [int(2*random()) for i in range(n)] if len(sys.argv) != 3: print(f"Usage: {sys.argv[0]} \n") @@ -13,5 +13,5 @@ if len(sys.argv) != 3: flips = int(sys.argv[1]) repeats = int(sys.argv[2]) -for i in range(repeats - 1): +for i in range(repeats): print(flipcoins(flips))