import numpy as np
import random
import matplotlib.pyplot as plt
import scienceplots
#Warning : As of version 2.0.0, you need to add import scienceplots before setting the style (plt.style.use('science')).
plt.style.use(['science', 'notebook'])
n = 6
print(f"{'x':>15s} {'y':>15s}")
for i in range(n):
print(f"{random.random():15.10f} {random.random():15.10f}")
x y
0.1692870693 0.5355835547
0.3285543176 0.5886628553
0.9149056063 0.3778905228
0.0160303602 0.7148574067
0.7984849726 0.7698328851
0.7007923555 0.3388337840
n2 = 600000
bmin, bmax = 0.0, 6.0
print(f"{'#1':>6s} {'#2':>6s} {'#3':>6s} {'#4':>6s} {'#5':>6s} {'#6':>6s} {'total':>6s}")
k = np.zeros(n)
for i in range(n2):
z = random.uniform(bmin, bmax)
iz = np.ceil(z)
for j in range(6):
if iz==j+1:
k[j] = k[j]+1
print(f"{k[0]:6.0f} {k[1]:6.0f} {k[2]:6.0f} {k[3]:6.0f} {k[4]:6.0f} {k[5]:6.0f} {np.sum(k):6.0f}")