#! /usr/bin/python3
# ==================================================================
#
# import random as random
#
# if random.random() < .70:
# print('A wins')
# else:
# print('B wins')
#
# The code means that A has an 70% chance of being selected
# (wining).
#
# The return value of random.random() is uniformly distributed
# across the range [0.0, 1.0) (from 0.0 inclusive to 1.0
# exclusive). random.random() has an equal chance of hitting
# any value in that range. This means that statistically 70%
# of the time a values below 0.70 occurs.
#
# ==================================================================
import random as R
event_probability = 0.70
number_of_tries = 1_000_000
true_count = 0
for _ in range(number_of_tries):
if R.random() < event_probability:
true_count += 1
calculated_probability = float(true_count) / float(number_of_tries)
print()
print('theoritical probability = {}'.format(event_probability))
print('number of tries = {}'.format(number_of_tries))
print('calculated true count = {}'.format(true_count))
print('calculated probability = {}'.format(calculated_probatility))
print()