The simulation has square as both shape1 and shape2 but it shouldn't happen if we run without replacement. I know the code runs well but I don't know how to solve this situation.
import pandas as pd
import random
creating the simulation
def simulation1():
shape1 = random.choice(["square", "pentagon", "octagon"])
return shape1
def simulation2():
shape2 = random.choice(["square", "pentagon", "octagon"])
return shape2
storing the simulation as a dataframe
data = []
for i in range(1000):
d = {"shape1": simulation1(), "shape2": simulation2()}
data.append(d)
df = pd.DataFrame(data)
Aucun commentaire:
Enregistrer un commentaire