From 23e613ffc42dd3eb92db23edd95b2de48bccf961 Mon Sep 17 00:00:00 2001 From: Daniel <59575049+lemoentjiez@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:06:27 +0200 Subject: [PATCH] Create fourth.py --- LabPSA_2/fourth.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 LabPSA_2/fourth.py diff --git a/LabPSA_2/fourth.py b/LabPSA_2/fourth.py new file mode 100644 index 0000000..435b78b --- /dev/null +++ b/LabPSA_2/fourth.py @@ -0,0 +1,17 @@ +import random +from numpy import pi, cos, sin, sqrt + +counter = 0 +for _ in range(100000): + (x1, y1) = (cos(random.uniform(0, 2*pi)), sin(random.uniform(0, 2*pi))) + (x2, y2) = (cos(random.uniform(0, 2 * pi)), sin(random.uniform(0, 2 * pi))) + (x3, y3) = (cos(random.uniform(0, 2 * pi)), sin(random.uniform(0, 2 * pi))) + len1 = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) + len2 = sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2) + len3 = sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2) + list1 = [len1, len2, len3] + list1.sort() + if list1[0] ** 2 + list1[1] ** 2 > list1[2] ** 2: + counter+=1 +print(counter/100000) +