From 6b8217b50fc729d25e48d0ef4a9730dd76b767ac Mon Sep 17 00:00:00 2001 From: Daniel <59575049+lemoentjiez@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:24:50 +0200 Subject: [PATCH] Update variables.py --- LabPSA_2/variables.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/LabPSA_2/variables.py b/LabPSA_2/variables.py index 8b13789..64c0103 100644 --- a/LabPSA_2/variables.py +++ b/LabPSA_2/variables.py @@ -1 +1,12 @@ +import random +ans, n = 0, 100000 +for i in range(n): + x, j = random.uniform(0, 1), 0 + while True: + y = random.uniform(0, 1) + if y > x: + break + j += 1 + ans += j +print(ans/n)