diff --git a/python-temel/pi.random.number.py b/python-temel/pi.random.number.py new file mode 100644 index 0000000..377b63c --- /dev/null +++ b/python-temel/pi.random.number.py @@ -0,0 +1,18 @@ +import random +import math + +def getpi(n): + count = 0 + for i in range(n): + x = random.random() + y = random.random() + if math.sqrt(x ** 2 + y ** 2) < 1: + count += 1 + return 4 * count / n + +while True: + n = int(input('Bir sayı giriniz:')) + if n == 0: + break + pi = getpi(n) + print(pi)