Files
2022-12-09 12:28:58 +02:00

18 lines
365 B
Python

import random
from numpy import sqrt
real = 0
positive = 0
for _ in range(10000):
c, b = random.uniform(-1, 1), random.uniform(-1, 1)
delta = b ** 2 - 4*c
if delta > 0:
real += 1
x1 = (-b + sqrt(delta))/2
x2 = (-b - sqrt(delta))/2
if x1 > 0 and x2 > 0:
positive += 1
print(real/10000)
print(positive/10000)